Skip to content

Commit 7b662fe

Browse files
authored
Merge pull request #20424 from mozilla/fix-page-delete-account-story
fix(storybook): fix page delete account storybook
2 parents 32f10ff + 065b12c commit 7b662fe

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

packages/fxa-settings/src/components/Settings/PageDeleteAccount/index.stories.tsx

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,40 @@ import { LocationProvider } from '@reach/router';
88
import { Meta } from '@storybook/react';
99
import { withLocalization } from 'fxa-react/lib/storybooks';
1010
import SettingsLayout from '../SettingsLayout';
11+
import { Account, AppContext } from '../../../models';
12+
import { mockAppContext, MOCK_ACCOUNT } from '../../../models/mocks';
1113

1214
export default {
1315
title: 'Pages/Settings/DeleteAccount',
1416
component: PageDeleteAccount,
1517
decorators: [withLocalization],
1618
} as Meta;
1719

18-
export const Default = () => (
19-
<LocationProvider>
20-
<SettingsLayout>
21-
<PageDeleteAccount />
22-
</SettingsLayout>
23-
</LocationProvider>
24-
);
20+
const accountWithPassword = {
21+
...MOCK_ACCOUNT,
22+
hasPassword: true,
23+
destroy: () => Promise.resolve(),
24+
} as unknown as Account;
25+
26+
const accountWithoutPassword = {
27+
...MOCK_ACCOUNT,
28+
hasPassword: false,
29+
destroy: () => Promise.resolve(),
30+
} as unknown as Account;
31+
32+
const storyWithContext = (account: Account) => {
33+
const story = () => (
34+
<LocationProvider>
35+
<AppContext.Provider value={mockAppContext({ account })}>
36+
<SettingsLayout>
37+
<PageDeleteAccount />
38+
</SettingsLayout>
39+
</AppContext.Provider>
40+
</LocationProvider>
41+
);
42+
return story;
43+
};
44+
45+
export const Default = storyWithContext(accountWithPassword);
46+
47+
export const WithoutPassword = storyWithContext(accountWithoutPassword);

0 commit comments

Comments
 (0)