Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('reset password : confirmReset : if valid token, reset password and delete token', (t) => {
const token = 'a9s8df7a98sd'
const password = 'foobar'
const email = 'foo@bar.com'
const sampleData = matchWithToken(email, token, 29)
const db = stubDB('byResetToken', token, sampleData)
const res = stubResponse()
const req = { body: { token, password } }
const confirmResetHandler = confirmReset(db)
confirmResetHandler(req, res)
td.verify(db.insert(td.matchers.argThat((n) => n.password === password && !n.metadata.resetToken), td.matchers.isA(Function)))
t.is(res.statusCode, 200, 'status code is 200')
})
it('should set routes on router', () => {
td.verify(router.get(td.matchers.isA(String), td.matchers.isA(Function)));
td.verify(router.post(td.matchers.isA(String), td.matchers.isA(Function)));
});
{
base: '/path',
input: '/path/src',
output: '/path/dist'
},
{
console
}
)
logger.start()
logger.error(new Error('Test 1'))
logger.error(new Error('Test 2'))
logger.finish()
td.verify(console.error('Test 1'), { times: 1 })
td.verify(console.error('Test 2'), { times: 1 })
td.verify(console.log('Finished with 2 error(s)'))
})
})
test('Creates project folder', () => {
td.verify(fs.mkdirAsync('test-api'))
})
test('Creates a function folder', () => {
test('Uploads the existing function', ()=> {
td.verify(lambda.getFunction(td.matchers.isA(Object)), { times: 1 })
td.verify(lambda.updateFunctionCode(td.matchers.isA(Object)), { times: 1 })
td.verify(lambda.updateFunctionConfiguration(td.matchers.isA(Object)), { times: 1 })
})
test('click', t => {
const ev = td.object(['preventDefault']);
const dispatch = td.function('dispatch');
const handler = td.function('handler');
const wrapper = shallow(Link);
wrapper.find('a').simulate('click', ev);
td.verify(ev.preventDefault(), { times: 1 });
td.verify(handler(ev), { times: 1 });
td.verify(dispatch(td.matchers.isA(Object)), { times: 1 });
});
test.cb('invokes sse.send() when handler is called', t => {
const sse = td.object({
send: () => {}
})
const db = td.object({
storeEvent: () => {}
})
const broadcast = createSubscriptions(sse, db)
const data = 'wowowowwww'
broadcast.setState(data)
td.verify(sse.send({ event: 'fair-analytics-event', data }))
td.verify(db.storeEvent(data))
t.end()
})
process.nextTick(() => {
td.verify(pool.connected('peer'))
td.verify(pool.disconnected('peer'))
})
t.equals(await pool.open(), false, 'already opened')
test('it marks test as failed if the errorCount is greater than 0', () => {
const {getLocalStandard, fail, run} = getContext()
const standardMock = {lintTextSync: td.func()}
td.when(getLocalStandard(td.matchers.anything())).thenReturn(standardMock)
td.when(standardMock.lintTextSync(td.matchers.anything(), td.matchers.anything())).thenReturn({errorCount: 2, results: [{messages: []}]})
const testPath = 'passingTest'
run({testPath, config: {}})
td.verify(fail(td.matchers.contains({test: {path: testPath, errorMessage: '', title: 'Standard error'}})))
})