How to use the testdouble.replace 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 joyent / cloudapi-gql / test / formatters.js View on Github external
beforeEach(() => {
    Handlers = TestDouble.replace('../lib/handlers', {
      network: TestDouble.func('network')
    });
    // fetch = TestDouble.func('fetch');
    request.plugins.cloudapi.fetch = () => {};
    Formatters = require('../lib/formatters');
  });
github ember-cli / ember-cli / tests / unit / utilities / merge-blueprint-options-test-disabled.js View on Github external
it("it works as a command's beforeRun()", function() {
    let command, availableOptions;

    td.replace(Blueprint, 'lookup', td.function());
    td.when(Blueprint.lookup('test-blueprint'), { ignoreExtraArgs: true }).thenReturn({
      availableOptions: [{ name: 'custom-blueprint-option', type: String }],
    });

    command = buildCommand();
    command.beforeRun(['test-blueprint']);

    availableOptions = map(command.availableOptions, 'name');
    expect(availableOptions).to.contain('verbose');
    expect(availableOptions).to.contain('custom-blueprint-option');
  });
});
github kineticadb / kinetica-kickbox-mapbox-gl / test / kickbox_spec.js View on Github external
it('should use the boundary to fit the bounds on the screen', () => {
        let options = {};
        let tableBoundaryResponse = 'empire';
        td.replace(kb._spec.helper, 'getTableBoundary');
        td.replace(map, 'fitBounds');
        td.when(kb._spec.helper.getTableBoundary(any()))
          .thenResolve(tableBoundaryResponse);
        td.when(map.fitBounds(tableBoundaryResponse, any()))
          .thenReturn('success');

        kb.zoomToBounds(map, options).should.eventually.deep.equal('success');
      });
    });
github ethereumjs / ethereumjs-client / test / service / fastethereumservice.js View on Github external
class PeerPool extends EventEmitter { }
  PeerPool.prototype.open = td.func()
  td.replace('../../lib/net/peerpool', PeerPool)
  td.replace('../../lib/net/protocol/flowcontrol')
  const Chain = td.constructor()
  Chain.prototype.open = td.func()
  td.replace('../../lib/blockchain', { Chain })
  const EthProtocol = td.constructor()
  const LesProtocol = td.constructor()
  td.replace('../../lib/net/protocol/ethprotocol', EthProtocol)
  td.replace('../../lib/net/protocol/lesprotocol', LesProtocol)
  class FastSynchronizer extends EventEmitter { }
  FastSynchronizer.prototype.start = td.func()
  FastSynchronizer.prototype.stop = td.func()
  FastSynchronizer.prototype.open = td.func()
  td.replace('../../lib/sync/fastsync', FastSynchronizer)
  const FastEthereumService = require('../../lib/service/fastethereumservice')

  t.test('should initialize correctly', async (t) => {
    let service = new FastEthereumService()
    t.ok(service.synchronizer instanceof FastSynchronizer, 'fast mode')
    t.equals(service.name, 'eth', 'got name')
    t.end()
  })

  t.test('should get protocols', async (t) => {
    let service = new FastEthereumService()
    t.ok(service.protocols[0] instanceof EthProtocol, 'fast protocols')
    t.notOk(service.protocols[1], 'no light protocol')
    service = new FastEthereumService({ lightserv: true })
    t.ok(service.protocols[0] instanceof EthProtocol, 'fast protocols')
    t.ok(service.protocols[1] instanceof LesProtocol, 'lightserv protocols')
github mysql / mysql-connector-nodejs / test / unit / Protocol / Client.js View on Github external
beforeEach('create fakes', () => {
                encodeClose = td.function();

                td.replace('../../../lib/Protocol/Protobuf/Adapters/Session', { encodeClose });

                FakeClient = require('../../../lib/Protocol/Client');
                encodeMessage = td.replace(FakeClient.prototype, 'encodeMessage');
            });
github artlogic / nabs / test / Task.js View on Github external
beforeEach(() => {
    td.replace(nabs, 'makeArray');
  });
github mysql / mysql-connector-nodejs / test / unit / DevAPI / TableUpdate.js View on Github external
beforeEach('create fakes', () => {
        preparing = td.function();

        td.replace('../../../lib/DevAPI/Preparing', preparing);
        tableUpdate = require('../../../lib/DevAPI/TableUpdate');
    });
github garden-io / garden / test / src / plugins / container.ts View on Github external
beforeEach(async () => {
    garden = await makeTestGarden(projectRoot, [gardenPlugin])
    ctx = garden.pluginContext
    env = garden.getEnvironment()

    td.replace(garden.buildDir, "syncDependencyProducts", () => null)
  })
github bustle / shep / test / deploy / exec.js View on Github external
test.before(()=> {
  process.chdir('../fixtures/test-api')

  apiGateway = td.replace('../../src/util/api-gateway')
  lambda = td.replace('../../src/util/lambda')
  deployFunction = td.replace('../../src/deploy-function/exec')

  td.when(apiGateway.createDeployment(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
  td.when(lambda.publishVersion(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
  td.when(lambda.addPermission(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
  td.when(lambda.updateAlias(td.matchers.isA(Object))).thenReturn(Promise.resolve({ AliasArn: 'arn:aws:lambda:us-east-1:654843952338:function:graph-api-graph-ql:'}))
  td.when(lambda.getAlias(td.matchers.isA(Object))).thenReturn(Promise.resolve({}))
  td.when(deployFunction(td.matchers.isA(Object)), { ignoreExtraArgs: true }).thenReturn(Promise.resolve({ FunctionName: 'test' }))

  const deploy = require('../../src/deploy/exec')

  return deploy({ region: 'us-east-1'})
})
github testdouble / test-smells / smells / unrealistic / fantasy / fantasy.js View on Github external
beforeEach: function () {
    td.replace(authenticator, 'login')
  },
  allRolesIfAuthenticated: function () {