Skip to content

Commit 1d20200

Browse files
committed
check that setitem is being called when logging in with passwordless
1 parent 4b64139 commit 1d20200

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/template-retail-react-app/app/pages/checkout/partials/contact-info.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ describe('passwordless and social disabled', () => {
105105

106106
describe('passwordless enabled', () => {
107107
let currentBasket = JSON.parse(JSON.stringify(scapiBasketWithItem))
108+
109+
beforeAll(() => {
110+
jest.spyOn(window.localStorage, 'setItem')
111+
})
112+
108113
beforeEach(() => {
114+
window.localStorage.setItem.mockClear()
115+
109116
global.server.use(
110117
rest.put('*/baskets/:basketId/customer', (req, res, ctx) => {
111118
currentBasket.customerInfo.email = validEmail
@@ -114,6 +121,10 @@ describe('passwordless enabled', () => {
114121
)
115122
})
116123

124+
afterAll(() => {
125+
window.localStorage.setItem.mockRestore()
126+
})
127+
117128
test('renders component', async () => {
118129
const {getByRole} = renderWithProviders(<ContactInfo isPasswordlessEnabled={true} />)
119130
expect(getByRole('button', {name: 'Checkout as Guest'})).toBeInTheDocument()
@@ -166,6 +177,7 @@ describe('passwordless enabled', () => {
166177
const withinForm = within(screen.getByTestId('sf-form-resend-passwordless-email'))
167178
expect(withinForm.getByText(/Check Your Email/i)).toBeInTheDocument()
168179
expect(withinForm.getByText(validEmail)).toBeInTheDocument()
180+
expect(window.localStorage.setItem).toHaveBeenCalled()
169181
})
170182

171183
// resend the email

0 commit comments

Comments
 (0)