test('Get SZ50 Stock Data', t => { t.plan(2); return stock.getSZ50().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array of stocks'); t.truthy(data.length === 50, 'It should return 50 records'); }); });
test.serial('Should send correct data when queried against a cuid', async t => { t.plan(2); const post = new Post({ name: 'Foo', title: 'bar', slug: 'bar', cuid: 'f34gb2bh24b24b2', content: 'Hello Mern says Foo' }); post.save(); const res = await request(app) .get('/api/posts/f34gb2bh24b24b2') .set('Accept', 'application/json'); t.is(res.status, 200); t.is(res.body.post.name, post.name); });
test('Get Index Data', t => { t.plan(1); return stock.getIndex().then(({ data }) => { t.truthy(data.length > 0, 'It should return an array of index data'); }); });
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(2); const query = { code: '600848', end: '15:00:00', }; return stock.getTodayTick(query).then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Object]', 'It should return the object of today tock price'); t.truthy(Object.prototype.toString.apply(data.zhubi_list) === '[object Array]', 'It should return an array of ticks'); }); });
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 All Stock Data', t => { t.plan(2); return stock.getAllStocks().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array of stocks'); t.truthy(data.length > 0, 'It should return more than one stocks'); }); });
test('Get Concepts Classify', t => { t.plan(2); return stock.getSinaConceptsClassified().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array concepts classified data'); t.truthy(data.length > 0, 'It should return more than one concepts classified data'); }); });
test('Get specified classifying Details', t => { t.plan(2); const options = { tag: 'gn_zndw', }; return stock.getSinaClassifyDetails(options).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 HS300 Stock Data', t => { t.plan(2); return stock.getHS300().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array of stocks'); t.truthy(data.length === 300, 'It should return 300 records'); }); });
test('Get Day Price', t => { t.plan(2); return stock.getSinaIndustryClassified().then(({ data }) => { t.truthy(Object.prototype.toString.apply(data) === '[object Array]', 'It should return an array industry data'); t.truthy(data.length > 0, 'It should return more than one industry data'); }); });
test('Get Week Price', t => { t.plan(3); const query = { code: '600848', ktype: 'week', }; 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 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 Minute Price', t => { t.plan(3); const query = { code: '600848', ktype: '15', }; 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'); }); });