Skip to content

Commit

Permalink
Added new unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sponglord committed Feb 9, 2024
1 parent cd6b003 commit cd5ffa1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/lib/src/components/Dropin/Dropin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ describe('Dropin', () => {
});
});

// TODO - this test doesn't do anything
describe('closeActivePaymentMethod', () => {
test('should close active payment method', async () => {
const dropin = new Dropin(checkout);
const component = await mount(dropin.render());
await component.update();

// re. TODO: dropin.dropinRef.state.activePaymentMethod = null, which is defined, so this assertion passes
expect(dropin.dropinRef.state.activePaymentMethod).toBeDefined();
dropin.closeActivePaymentMethod();
expect(dropin.dropinRef.state.activePaymentMethod).toBeNull();
Expand Down Expand Up @@ -155,4 +157,24 @@ describe('Dropin', () => {
expect(await screen.findByText(/An unknown error occurred/i)).toBeTruthy();
});
});

describe('Complying with local regulations', () => {
test('when countryCode is Finland openFirstPaymentMethod & openFirstStoredPaymentMethod should be false', async () => {
checkout.options.countryCode = 'FI';

const dropin = new Dropin(checkout);

expect(dropin.props.openFirstPaymentMethod).toBe(false);
expect(dropin.props.openFirstStoredPaymentMethod).toBe(false);
});

test('if openFirstPaymentMethod & openFirstStoredPaymentMethod are set by merchant then these values should be used', async () => {
checkout.options.countryCode = 'FI';

const dropin = new Dropin(checkout, { openFirstPaymentMethod: true, openFirstStoredPaymentMethod: true });

expect(dropin.props.openFirstPaymentMethod).toBe(true);
expect(dropin.props.openFirstStoredPaymentMethod).toBe(true);
});
});
});

0 comments on commit cd5ffa1

Please sign in to comment.