Skip to content

Commit 48e4d68

Browse files
Merge pull request #20044 from mozilla/fix-broken-storybook-again
polish(settings): fix broken storybooks
2 parents 8a1b952 + 862724d commit 48e4d68

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

packages/fxa-settings/src/models/mocks.tsx

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,27 @@ export function mockSession(
124124
}
125125

126126
export function mockAuthClient() {
127+
const mockSessionStatus = {
128+
state: 'verified',
129+
details: {
130+
verified: true,
131+
accountEmailVerified: true,
132+
sessionVerified: true,
133+
sessionVerificationMeetsMinimumAAL: true,
134+
sessionVerificationMethod: 'email',
135+
},
136+
};
127137
// There are plenty more methods to mock here, but this is these are the ones
128138
// that get commonly used.
129-
return {
130-
sessionStatus: jest.fn().mockReturnValue({
131-
state: 'verified',
132-
details: {
133-
verified: true,
134-
accountEmailVerified: true,
135-
sessionVerified: true,
136-
sessionVerificationMeetsMinimumAAL: true,
137-
sessionVerificationMethod: 'email',
138-
},
139-
}),
140-
} as unknown as AuthClient;
139+
if (typeof jest !== 'undefined') {
140+
return {
141+
sessionStatus: jest.fn().mockResolvedValue(mockSessionStatus),
142+
} as unknown as AuthClient;
143+
} else {
144+
return {
145+
sessionStatus: () => Promise.resolve(mockSessionStatus),
146+
} as unknown as AuthClient;
147+
}
141148
}
142149

143150
export function mockSensitiveDataClient() {

0 commit comments

Comments
 (0)