How to use the testdouble/dist/testdouble.matchers 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 paypal / paypal-card-components / test / component.js View on Github external
};

    fakeTokenizationPayload = {
      payment_source: {
        card: {
          last_digits: '1111',
          card_type:   'VISA'
        }
      },
      links: []
    };
    btClientCreate = td.replace(btClient, 'create');
    contingencyFlowStart = td.replace(contingencyFlow, 'start');

    fakeHostedFieldsInstance = td.object([ 'tokenize' ]);
    td.when(fakeHostedFieldsInstance.tokenize(td.matchers.isA(Object))).thenResolve(fakeTokenizationPayload);
    hostedFieldsCreate = td.replace(hostedFields, 'create');

    fakeBtClient = {
      getConfiguration: (conf) => conf
    };

    td.when(hostedFieldsCreate(td.matchers.isA(Object))).thenResolve(fakeHostedFieldsInstance);
    td.when(btClientCreate(td.matchers.isA(Object))).thenResolve(fakeBtClient);

    const button = document.createElement('button');
    button.id = 'button';

    // $FlowFixMe
    document.body.appendChild(button);
  });
github paypal / paypal-card-components / test / contingency-flow.js View on Github external
it('renders a zoid component', () => {
    contingencyFlow.start('https://example.com?cart_id=abc123&action=action&xcomponent=1&flow=contingency');

    td.verify(fakeContingencyInit({
      action:              'action',
      xcomponent:           '1',
      flow:                'contingency',
      cart_id:             'abc123',
      onContingencyResult: td.matchers.isA(Function),
      onError:             td.matchers.isA(Function)
    }));

    td.verify(fakeContingencyComponentRender(document.body));
  });
github paypal / paypal-card-components / test / component.js View on Github external
it('rejects with an error if the error has a details array, but is not a 3ds contingency', () => {
      const expectedError = {
        details: [
          'its pretty baad'
        ]
      };

      td.when(fakeHostedFieldsInstance.tokenize(td.matchers.isA(Object)))
        .thenReject(expectedError);

      return HostedFields.render(renderOptions, '#button').then((handler) => {
        return handler.submit().then(rejectIfResolves).catch((err) => {
          assert.equal(expectedError, err);
        });
      });
    });
github paypal / paypal-card-components / test / contingency-flow.js View on Github external
it('renders a zoid component', () => {
    contingencyFlow.start('https://example.com?cart_id=abc123&action=action&xcomponent=1&flow=contingency');

    td.verify(fakeContingencyInit({
      action:              'action',
      xcomponent:           '1',
      flow:                'contingency',
      cart_id:             'abc123',
      onContingencyResult: td.matchers.isA(Function),
      onError:             td.matchers.isA(Function)
    }));

    td.verify(fakeContingencyComponentRender(document.body));
  });
github paypal / paypal-card-components / test / happy.js View on Github external
client = window.paypal.client({
            env:  'production',
            auth: {
                production: 'PROD'
            }
        });
        btClientCreate = td.replace(btClient, 'create');

        fakeHostedFieldsInstance = td.object([ 'tokenize' ]);
        hostedFieldsCreate = td.replace(hostedFields, 'create');

        fakeBtClient = {
            getConfiguration: (conf) => conf
        };

        td.when(hostedFieldsCreate(td.matchers.isA(Object))).thenResolve(fakeHostedFieldsInstance);
        td.when(btClientCreate(td.matchers.isA(Object))).thenResolve(fakeBtClient);
    });
github paypal / paypal-card-components / test / happy.js View on Github external
return client.HostedFields.render(renderOptions).then(() => {
            td.verify(btClientCreate({
                authorization: 'PROD',
                configuration: td.matchers.isA(Object)
            }));
            td.verify(hostedFieldsCreate({
                client:      fakeBtClient,
                paymentsSdk: true
            }));
        });
    });