Skip to content

Commit

Permalink
test: Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julianajlk committed Apr 9, 2024
1 parent 521c606 commit e1b548d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/payment/AlertCodeMessages.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
SingleEnrollmentCodeWarning,
EnrollmentCodeQuantityUpdated,
TransactionDeclined,
DynamicPaymentMethodsNotCompatibleError,
BasketChangedError,
} from './AlertCodeMessages';

const mockStore = configureMockStore();
Expand Down Expand Up @@ -51,3 +53,27 @@ describe('TransactionDeclined', () => {
expect(tree).toMatchSnapshot();
});
});

describe('DynamicPaymentMethodsNotCompatibleError', () => {
it('should render with values', () => {
const component = (
<IntlProvider locale="en">
<DynamicPaymentMethodsNotCompatibleError />
</IntlProvider>
);
const { container: tree } = render(component);
expect(tree).toMatchSnapshot();
});
});

describe('BasketChangedError', () => {
it('should render with values', () => {
const component = (
<IntlProvider locale="en">
<BasketChangedError />
</IntlProvider>
);
const { container: tree } = render(component);
expect(tree).toMatchSnapshot();
});
});
12 changes: 12 additions & 0 deletions src/payment/__snapshots__/AlertCodeMessages.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`BasketChangedError should render with values 1`] = `
<div>
Your cart has changed since navigating to this page. Please reload the page and verify the product you are purchasing.
</div>
`;

exports[`DynamicPaymentMethodsNotCompatibleError should render with values 1`] = `
<div>
The payment method you have selected is not available in your country. Please select another payment method.
</div>
`;

exports[`EnrollmentCodeQuantityUpdated should render with values 1`] = `
<div>
<h6>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('<CardHolderInformation />', () => {
fireEvent.change(screen.getByLabelText('Country (required)'), { target: { value: 'US' } });

expect(getCountryStatesMap).toHaveBeenCalledWith('US');
expect(isPostalCodeRequired).toHaveBeenCalledWith('US');
expect(isPostalCodeRequired).toHaveBeenCalledWith('US', false); // DPM enabled added to the call
});
});
describe('purchasedForOrganization field', () => {
Expand Down
21 changes: 21 additions & 0 deletions src/payment/data/redux.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,27 @@ describe('redux tests', () => {
isRedirect: true, // this is also now true.
});
});

it('is a Stripe dynamic payment methods redirect', () => {
global.history.pushState({}, '', '?payment_intent=pi_123dummy');
store = createStore(combineReducers({
payment: reducer,
}));

const result = paymentSelector(store.getState());
expect(result).toEqual({
loading: true,
loaded: false,
submitting: false,
redirect: false, // This is a different kind of redirect, so still false.
products: [],
isCouponRedeemRedirect: false,
isBasketProcessing: false,
isEmpty: false,
isPaymentRedirect: true, // this is now true
isRedirect: false,
});
});
});
});

Expand Down

0 comments on commit e1b548d

Please sign in to comment.