test.serial('Running shrinkpack does not affect installation', async t => { const controlModuleTree = await testUtil.getAllDirFiles(path.join(controlApp, 'node_modules')); const shrinkpackModuleTree = await testUtil.getAllDirFiles(path.join(shrinkpackApp, 'node_modules')); t.deepEqual(shrinkpackModuleTree, controlModuleTree); });
test.serial('Running shrinkpack updates the shrinkwrap file', async t => { await testUtil.shrinkwrap(shrinkpackApp); const beforeShrinkpack = await testUtil.getShrinkwrapFile(shrinkpackApp); await testUtil.shrinkpack(shrinkpackApp); const afterShrinkpack = await testUtil.getShrinkwrapFile(shrinkpackApp); t.not(beforeShrinkpack, afterShrinkpack); });
test.serial('All deps in shrinkpacked shrinkwrap have resolved prop and point to local file', async t => { const afterShrinkpack = await testUtil.getShrinkwrapFile(shrinkpackApp); const {dependencies} = JSON.parse(afterShrinkpack); const assertAllResolves = deps => { Object.keys(deps).forEach(depName => { const dep = deps[depName]; t.true(dep.resolved.indexOf('./node_shrinkwrap/') > -1); if (dep.dependencies) { assertAllResolves(dep.dependencies); } }); }; assertAllResolves(dependencies); });
test.serial('Reinstalling from shrinkpack produces expected output', async t => { await testUtil.rmDirs(path.join(shrinkpackApp, 'node_modules')); await testUtil.npmInstall(shrinkpackApp); const controlModuleTree = await testUtil.getAllDirFiles(path.join(controlApp, 'node_modules')); const shrinkpackModuleTree = await testUtil.getAllDirFiles(path.join(shrinkpackApp, 'node_modules')); t.deepEqual(shrinkpackModuleTree, controlModuleTree); });
test.serial('Correct npm version was installed', async t => { const actualNpmVersion = await testUtil.getNpmVersion(); t.is(actualNpmVersion, process.env.NPM_VERSION); });
test.serial('Installing a non-shrinkpacked project produces expected output', async t => { await testUtil.createTestApp(nonShrinkpackApp, testPackageJson); await testUtil.npmInstall(nonShrinkpackApp); const controlModuleTree = await testUtil.getAllDirFiles(path.join(controlApp, 'node_modules')); const nonShrinkpackModuleTree = await testUtil.getAllDirFiles(path.join(nonShrinkpackApp, 'node_modules')); t.deepEqual(nonShrinkpackModuleTree, controlModuleTree); await testUtil.rmDirs(nonShrinkpackApp); });
test('Receiving a 200-OK without body', async t => { const eut = (new MessageSet()).setApiKey('x').setUserId('y').setPlatform('z'); const msg = eut.newMessage().setMessage('abc'); const error = await t.throws(eut.sendMessageSet()); t.true(error instanceof errors.EmptyCreateResponse, 'The error should be an instance of the EmptyCreateResponse class'); scope.done(); });
test('logger factory functionality', t => { var inst = logger('test'); t.true(isFunction(logger), 'The logger module should export a function'); t.is(inst.name, 'debug', 'Invoking the function should return an instance of the debug module'); t.notThrows(() => logger(), 'Should be able to create an instance of the logger without providing a namespace'); });
test( 'validateFeedback should return false given feedback is true and type is agent', t => { t.is(inst.setAsTypeAgent().setAsFeedback().validateFeedback(), false); } );
test('cannotBeUpdated - update-derived error', t => { const err = new Error('500'); t.is(inst.setAsUpdateErrored(err).cannotBeUpdated(), err, 'Should return the update error as the return-value of invocation'); });
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'); }); });