test('renders properly', t => { const wrapper = shallowWithIntl( <PostListItem {...props} /> ); t.truthy(wrapper.hasClass('single-post')); t.is(wrapper.find('Link').first().prop('children'), post.title); t.regex(wrapper.find('.author-name').first().text(), new RegExp(post.name)); t.is(wrapper.find('.post-desc').first().text(), post.content); });
test('should ignore missing/non-github modules', t => { return api.findNodeModulesOnGithub(['non-existent-module', 'no-git-module', 'no-repo-module', 'proper-git-module'], './test/').then(githubInfos => { t.is(githubInfos.length, 4); t.truthy(githubInfos[0].error); t.truthy(githubInfos[1].error); t.truthy(githubInfos[2].error); t.is(githubInfos[3].githubInfo.user, 'musically-ut'); t.is(githubInfos[3].githubInfo.repo, 'lovely-forks'); }); });
test('translate some text and get the raw output alongside', async t => { try { const res = await translate('vertaler', {raw: true}); t.truthy(res.raw); } catch (err) { t.fail(err.code); } });
test('renders properly', t => { const wrapper = shallow( <App {...props} /> ); // t.is(wrapper.find('Helmet').length, 1); t.is(wrapper.find('Header').length, 1); t.is(wrapper.find('Footer').length, 1); t.is(wrapper.find('Header').prop('toggleAddPost'), wrapper.instance().toggleAddPostSection); t.truthy(wrapper.find('Header + div').hasClass(styles.container)); t.truthy(wrapper.find('Header + div').children(), children); });
test(t => { let state = empty(); let addTodoAction = actions.todo.add(0, "test name", "test description"); state = todos(state, addTodoAction); t.is(state.todos.size, 1); state = todos(state, actions.todo.remove(0)); t.truthy(is(empty(), state)); t.is(state.todos.size, 0); });
test('calls onDelete', t => { const onDelete = sinon.spy(); const wrapper = shallowWithIntl( <PostListItem post={post} onDelete={onDelete} /> ); wrapper.find('.post-action > a').first().simulate('click'); t.truthy(onDelete.calledOnce); });
test('Get Long Period Rank Data by month', t => { const options = { period: 'month', pageNo: 1, pageSize: 100, }; return stock.longPeriodRank(options).then(({ data }) => { t.truthy(data.items.length === 100, 'It should return 100 records'); }); });
test('Get Day Price', t => { t.plan(3); const query = { code: '600848' }; return stock.getHistory(query).then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Object]', 'It should return the object of day price'); t.truthy(data.record, 'The returned data should have a key with name `record`'); t.truthy(data.record.length, 'It should not return an empty array'); }); });
test('Get Tick Data', t => { t.plan(1); const query = { code: '600848', date: '2015-12-31', }; return stock.getTick(query).then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return the object of day price'); }); });
test('Get Tick Data', t => { t.plan(1); return stock.getTodayAll().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array of today stock data'); }); });
test('Get default classifying Details', t => { t.plan(2); return stock.getSinaClassifyDetails().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array of stocks of an industry'); t.truthy(data.length > 0, 'It should return more than one stocks in an industry'); }); });
test('Get Long Period Rank Data by month', t => { const options = { period: 'quarter', pageNo: 1, pageSize: 100, }; return stock.longPeriodRank(options).then(({ data }) => { t.truthy(data.items.length === 100, 'It should return 100 records'); }); });