How to use the testdouble/dist/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 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 / component.js View on Github external
selector: '#credit-card'
        }
      }
    };

    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
github paypal / paypal-card-components / test / component.js View on Github external
HostedFields.render(renderOptions, '#button2').then((handler) => {
      const tokenizationData = {
        foo: 'bar'
      };
      td.replace(handler, 'submit');
      td.when(handler.submit()).thenResolve(tokenizationData);
      btn.click();

      setTimeout(() => {
        td.verify(renderOptions.onApprove(tokenizationData));
        done();
      }, 100);
    }).catch(done);
  });
github paypal / paypal-card-components / test / contingency-flow.js View on Github external
beforeEach(() => {
    fakeContingencyInit = td.replace(contingencyFlow.contingency, 'Component');
    fakeContingencyComponentRender = td.func();
    td.when(fakeContingencyInit(), { ignoreExtraArgs: true }).thenReturn({
      render: fakeContingencyComponentRender
    });
  });
github paypal / paypal-card-components / test / component.js View on Github external
it('can setup click handler for provided button if onApprove function is passed', () => {
    const btn = document.createElement('button');

    btn.id = 'button2';
    if (document.body) {
      document.body.appendChild(btn);
    }

    td.replace(btn, 'addEventListener');

    return HostedFields.render(renderOptions, '#button2').then(() => {
      td.verify(btn.addEventListener('click', td.matchers.isA(Function)));
    });
  });
github paypal / paypal-card-components / test / happy.js View on Github external
beforeEach(() => {
        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
beforeEach(() => {
        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 / component.js View on Github external
number: {
          selector: '#credit-card'
        }
      }
    };

    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';