How to use the testdouble.function 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 mysql / mysql-connector-nodejs / test / unit / DevAPI / Limiting.js View on Github external
it('forces an associated statement to be re-prepared the first time its called', () => {
            const forceReprepare = td.function();
            const statement = limiting({ preparable: { forceReprepare } }).limit(1);

            expect(td.explain(forceReprepare).callCount).to.equal(1);

            statement.offset(2);

            expect(td.explain(forceReprepare).callCount).to.equal(1);
        });
github mysql / mysql-connector-nodejs / test / unit / Protocol / Client.js View on Github external
it('registers a `close` event listener for the provided stream', () => {
            const stream = { on };
            const handleServerClose = td.function();

            td.when(on('close')).thenCallback();
            td.when(handleServerClose('foo')).thenReturn();

            Client.call({ handleServerClose }, stream);

            return expect(td.explain(handleServerClose).callCount).to.equal(1);
        });
    });
github mysql / mysql-connector-nodejs / test / unit / DevAPI / Client.js View on Github external
beforeEach('create fakes', () => {
            acquire = td.function();
            destroy = td.function();
            start = td.function();
        });
github sebinsua / neo4j-simple / test / database / connection / query.js View on Github external
function getDriver () {
  const getSession = td.function()
  const runQuery = td.function()
  const closeSession = td.function()
  const subscribeToQuery = td.function()

  td.when(runQuery(), { ignoreExtraArgs: true }).thenReturn({
    subscribe: subscribeToQuery
  })

  td.when(getSession()).thenReturn({
    run: runQuery,
    close: closeSession
  })

  const driver = {
    session: getSession
  }

  return { driver, getSession, runQuery }
github mysql / mysql-connector-nodejs / test / unit / DevAPI / SessionConfigManager.js View on Github external
beforeEach('create fakes', () => {
            exists = td.function();
            remove = td.function();
        });
github mysql / mysql-connector-nodejs / test / unit / DevAPI / Session.js View on Github external
beforeEach('create fakes', () => {
            clientProto = Object.assign({}, Client.prototype);

            authenticate = td.function();
            capabilitiesGet = td.function();

            Client.prototype.authenticate = authenticate;
            Client.prototype.capabilitiesGet = capabilitiesGet;

            td.when(authenticate(), { ignoreExtraArgs: true }).thenResolve();
        });
github mysql / mysql-connector-nodejs / test / unit / DevAPI / TableDelete.js View on Github external
beforeEach('create fakes', () => {
            forceRestart = td.function();
        });
github mysql / mysql-connector-nodejs / test / unit / DevAPI / Client.js View on Github external
beforeEach('create fakes', () => {
            destroy = td.function();
        });
github valor-software / ng2-dragula / modules / ng2-dragula / src / spec / dragula.service.spec.ts View on Github external
const subscribeSync = (obs: Observable, trigger: Function, n = 1): T => {
    let called: T;
    let fn = td.function();
    let subs = obs.pipe(take(n > 0 ? n : 1)).subscribe(ev => {
      fn(ev);
      called = ev;
    });
    trigger();
    subs.unsubscribe();
    expect().toVerify({ called: fn(td.matchers.isA(Object)), times: n })
    return called;
  };