How to use the testdouble.verify function in testdouble

To help you get started, we’ve selected a few testdouble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github timwis / enviar / test / server / reset-password.js View on Github external
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')
})
github albertogasparin / react-starterkit / api / __tests__ / unit.js View on Github external
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)));
  });
github oro-oss / houl / test / specs / loggers / build-logger.spec.js View on Github external
{
        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)'))
  })
})
github bustle / shep / test / new / exec.js View on Github external
test('Creates project folder', () => {
  td.verify(fs.mkdirAsync('test-api'))
})
test('Creates a function folder', () => {
github bustle / shep / test / deploy-function / exec-existing-func.js View on Github external
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 })
})
github kuy / redux-tower / src / react / __tests__ / link.js View on Github external
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 });
});
github vesparny / fair-analytics / test / wire-subscriptions.spec.js View on Github external
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()
})
github ethereumjs / ethereumjs-client / test / net / peerpool.js View on Github external
process.nextTick(() => {
      td.verify(pool.connected('peer'))
      td.verify(pool.disconnected('peer'))
    })
    t.equals(await pool.open(), false, 'already opened')
github TheBrainFamily / jest-runner-standard / run.spec.js View on Github external
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'}})))
})