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('Receiving an API-specific error-body from send() invocation', async t => { const eut = (new MessageStateWrapper('x', 'y')).setMessageId('abc'); eut._state.setAsCreateCompleted(); const error = await t.throws(eut.update()); t.true(error instanceof errors.BadStatusUpdateResponse, 'The error should be an instance of the BadStatusUpdateResponse class'); t.true(eut.cannotBeUpdated().error instanceof errors.BadStatusUpdateResponse); scope.done(); });
test('Receiving an API-specific error-body from send() invocation', async t => { const eut = (new MessageStateWrapper('x', 'y')) .setPlatform('z') .setMessage('abc'); const error = await t.throws(eut.send()); t.true(error instanceof errors.BadStatusCreateResponse, 'The error should be an instance of the BadStatusCreateResponse class'); t.true(eut.cannotBeUpdated().error instanceof errors.BadStatusCreateResponse); scope.done(); });
test('Receiving an API-specific error-body from send() invocation', 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.BadStatusCreateResponse, 'The error should be an instance of the BadStatusCreateResponse class'); scope.done(); });
test('All fixtures map to actual API', (t) => { const fixtureKeys = R.keys(FixtureAPI).sort() const apiKeys = R.keys(API.create()) const intersection = R.intersection(fixtureKeys, apiKeys).sort() // There is no difference between the intersection and all fixtures t.true(R.equals(fixtureKeys, intersection)) })
test('Receiving a valid response', t => { return eut.sendMessageSet().then(eut => { t.deepEqual(eut.getCreateResponse(), resp); t.true(eut.createEntryStarted(), 'createEntryStarted flag should be true'); t.true(eut.createEntryCompleted(), 'createEntryCompleted flag should be true'); }).catch(e => console.error(e)); });
test('Invoking send() on a message lacking necessary fields', async t => { const eut = new MessageSet(); const msg = eut.newMessage(); const error = await t.throws(eut.sendMessageSet()); t.true(error instanceof errors.RequiredKeysNotSet, 'The error should be an instance of the RequiredKeysNotSet class'); });
test('Invoking send() on a message lacking necessary fields', async t => { const eut = (new MessageStateWrapper('x', 'y')); eut._state.setAsCreateCompleted(); const error = await t.throws(eut.update()); t.true(error instanceof errors.RequiredKeysNotSet, 'The error should be an instance of the RequiredKeysNotSet class'); });