How to use the sinon.stub function in sinon

To help you get started, we’ve selected a few sinon 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 CircleCI-Public / circleci-demo-javascript-express / client / modules / App / __tests__ / Components / Header.spec.js View on Github external
test('renders the header properly', t => {
  const router = {
    isActive: sinon.stub().returns(true),
  };
  const wrapper = shallow(
    <header> {}} intl={intlProp} toggleAddPost={() =&gt; {}} /&gt;,
    {
      context: {
        router,
        intl,
      },
    }
  );

  t.truthy(wrapper.find('Link').first().containsMatchingElement());
  t.is(wrapper.find('a').length, 1);
});
</header>
github MyEtherWallet / MyEtherWallet / tests / unit / specs / src / dapps / ManageENS / containers / EnsBidContainer / EnsBidContainer.spec.js View on Github external
describe('EnsBidContainer.vue', () => {
  let localVue, i18n, wrapper, store;
  const checkDomain = sinon.stub();
  const generateKeyPhrase = sinon.stub();
  const startAuctionAndBid = sinon.stub();
  const revealBid = sinon.stub();
  const sendBid = sinon.stub();

  const domainName = 'domainName';
  const mockRoute = {
    fullPath: 'auction'
  };
  const mockRouter = {
    replace: sinon.stub(),
    history: {
      current: {
        path: '/interface/dapps/register-domain'
      }
    }
  };
github alphagov / pay-frontend / test / middleware / csrf.js View on Github external
beforeEach(function () {
    status = sinon.stub(response, 'status')
    render = sinon.stub(response, 'render')
    next = sinon.spy()
    nock.cleanAll()
  })
github mozillach / gh-projects-content-queue / test / _github-client.js View on Github external
const getGithubClient = () => ({
    issues: {
        addLabels: sinon.stub(),
        removeLabel: sinon.stub(),
        createComment: sinon.stub(),
        edit: sinon.stub(),
        addAssigneesToIssue: sinon.stub(),
        getForRepo: sinon.stub(),
        create: sinon.stub()
    },
    projects: {
        moveProjectColumn: sinon.stub(),
        getProjectCards: sinon.stub(),
        createProjectColumn: sinon.stub(),
        createProjectCard: sinon.stub(),
        deleteProjectCard: sinon.stub(),
        moveProjectCard: sinon.stub(),
        getRepoProjects: sinon.stub(),
        createRepoProject: sinon.stub(),
        getProjectColumns: sinon.stub()
    },
    hasNextPage: sinon.stub(),
    getNextPage: sinon.stub()
});
github ministryofjustice / apvs-external-web / test / unit / routes / apply / eligibility / new-claim / test-journey-information.js View on Github external
beforeEach(function () {
    urlPathValidatorStub = sinon.stub()
    newClaimStub = sinon.stub()
    insertNewClaimStub = sinon.stub()
    visitorPrisonerCheckStub = sinon.stub()
    insertRepeatDuplicateClaimStub = sinon.stub()

    var route = proxyquire('../../../../../../app/routes/apply/eligibility/new-claim/journey-information', {
      '../../../../services/validators/url-path-validator': urlPathValidatorStub,
      '../../../../services/data/visitor-prisoner-check': visitorPrisonerCheckStub,
      '../../../../services/domain/new-claim': newClaimStub,
      '../../../../services/data/insert-new-claim': insertNewClaimStub,
      '../../../../services/data/insert-repeat-duplicate-claim': insertRepeatDuplicateClaimStub
    })
    app = routeHelper.buildApp(route)
  })
github bookshelf / trigger-then / test / index.js View on Github external
beforeEach(function () {
      sync = sinon.stub().returns(response);
      promise = sinon.stub().resolves(response);
    });
github mcibique / vue-testing-examples / src / store / auth / actions.spec.js View on Github external
beforeEach(function () {
    this.authServiceMock = mockService(AUTH_SERVICE_ID);

    this.commitStub = sinon.stub();
    this.dispatchStub = sinon.stub();
    this.actionContext = {
      commit: this.commitStub,
      dispatch: this.dispatchStub
    };
  });
github optimizely / javascript-sdk / packages / optimizely-sdk / lib / core / event_builder / event_helpers.tests.js View on Github external
configObj = {
      accountId: 'accountId',
      projectId: 'projectId',
      revision: '69',
      anonymizeIP: true,
      botFiltering: true,
    };

    sinon.stub(projectConfig, 'getEventId');
    sinon.stub(projectConfig, 'getVariationIdFromExperimentAndVariationKey');
    sinon.stub(projectConfig, 'getExperimentId');
    sinon.stub(projectConfig, 'getLayerId');
    sinon.stub(projectConfig, 'getAttributeId');

    sinon.stub(fns, 'uuid').returns('uuid');
    sinon.stub(fns, 'currentTimestamp').returns(100);
  });
github pnp / office365-cli / src / o365 / spo / commands / customaction / customaction-clear.spec.ts View on Github external
it('doesn\'t fail if the parent doesn\'t define options', () => {
    sinon.stub(Command.prototype, 'options').callsFake(() => { return undefined; });
    const options = (command.options() as CommandOption[]);
    Utils.restore(Command.prototype.options);
    assert(options.length > 0);
  });
github accordproject / concerto / packages / composer-playground / src / app / editor / editor.component.spec.ts View on Github external
it('should handle namespace change', fakeAsync(() => {
            component['currentFile'] = 'myFile';
            let updateFilesStub = sinon.stub(component, 'updateFiles');
            let findFileStub = sinon.stub(component, 'findFileIndex').returns(0);
            let currentFileStub = sinon.stub(component, 'setCurrentFile');

            component['files'] = ['myFile'];

            mockFileService.namespaceChanged$ = {
                takeWhile: sinon.stub().returns({
                    subscribe: (callback) => {
                        let newName = 'bob';
                        callback(newName);
                    }
                })
            };

            component.ngOnInit();

            tick();