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.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('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('extracts compact Github repo info correctly ', t => { const pkgJSON = { repository: 'user/repo' }; t.deepEqual(api.getProjectUserRepo(pkgJSON), { user: 'user', repo: 'repo' }); });
parserTests.forEach(({ name, input, idents, hasDefault, props }) => { test(`parser-${name}`, t => { return parser.run(__dirname, input).then(actual => { t.deepEqual(actual.idents, new Set(idents || [])); t.deepEqual(actual.props, new Set(props || [])); t.is(actual.hasDefault, hasDefault || false); }); }); });
test('has correct props', t => { const wrapper = mountWithIntl( <PostListItem {...props} /> ); t.deepEqual(wrapper.prop('post'), props.post); t.is(wrapper.prop('onClick'), props.onClick); t.is(wrapper.prop('onDelete'), props.onDelete); });
test('Initial state', t => { t.is(inst.api_key, null); t.is(inst.user_id, null); t.is(inst.platform, null); t.is(inst.type, null); t.deepEqual(inst.messages, []); t.true(inst._state instanceof MessageLifecycleState); });
test('method defaults to GET', t => { const reply = { foo: 'bar' }; nock(API_URL) .get('/foo') .reply(200, reply); return callApi('foo').then(response => { t.deepEqual(response, reply); }); });
test('failure', (t) => { const mock = { username: '', password: '' } const step = stepper(login(mock)) t.deepEqual(step(), put(LoginActions.loginFailure('WRONG'))) })
test('GET /file.test returns 200 & the file', async t => { const filepath = path.join('files', 'message.txt'); const file = fs.writeFileSync(filepath, 'Hello tester'); const content = fs.readFileSync(filepath); const response = await request.get(`${host}/message.txt`); t.deepEqual(response.body, content); });
test('should create generic template', t => { let bot = new Bot(123); t.throws(bot.createGenericTemplate, 'Generic template requires an array of elements'); t.deepEqual(bot.createGenericTemplate([1,2,3]), { template_type: 'generic', elements: [1,2,3] }); });
test('setAsUpdateCompleted', t => { const bdy = {ack: true}; inst.setAsUpdateCompleted(bdy); t.is(inst.updateEntryCompleted(), true, 'Should have set the update.completed property to true'); t.deepEqual(inst.getUpdateResponse(), bdy, 'The value of the response should be the IV given at invocation'); });
test('should create url button', t => { let bot = new Bot(123); let title = 'Test'; let url = 'http://google.com'; let button = bot.createWebUrlButton(title, url); t.deepEqual(button, { type: 'web_url', title: title, url: url }); });
test('Can clean empty lists', t => { const example = { myinfo: {foo: 'bar'}, }; t.deepEqual(cleanListData(example), { myinfo: {foo: 'bar'}, list: [], }); });
test('todo reducer should handle initial state', (t) => { t.deepEqual(todos(undefined, {}), [{id: 0, text: 'DUMMY', complete: false}]) })