This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 178
/
Settings.story.js
122 lines (116 loc) · 2.96 KB
/
Settings.story.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { storiesOf } from '@storybook/vue'
import { action } from '@storybook/addon-actions'
import Settings from '@/authuser/pages/Settings'
import VerificationWarning from '@/authuser/components/Settings/VerificationWarning'
import { currentUserMock, groupsMock } from '>/mockdata'
import { createDatastore, statusMocks, storybookDefaults as defaults } from '>/helpers'
import * as factories from '>/enrichedFactories'
const datastore = createDatastore({
auth: {
getters: {
user: () => currentUserMock,
saveStatus: () => statusMocks.default(),
changeEmailStatus: () => statusMocks.default(),
changePasswordStatus: () => statusMocks.default(),
failedEmailDeliveries: () => [],
},
actions: {
update: action('update'),
changePassword: action('changePassword'),
changeEmail: action('changeEmail'),
},
modules: {
push: {
namespaced: true,
getters: {
enabled: () => false,
pending: () => false,
},
},
},
},
currentGroup: {
getters: {
value: () => groupsMock[0],
getNotificationTypeStatus: () => () => ({}),
},
},
groups: {
getters: {
mine: () => groupsMock,
},
},
users: {
getters: {
resendVerificationCodeStatus: () => statusMocks.default(),
requestDeleteAccountStatus: () => statusMocks.default(),
resendVerificationCodeSuccess: () => false,
},
actions: {
resendVerification: action('resend'),
},
},
unsubscribe: {
getters: {
allEmailsPerGroupStatus: () => statusMocks.default(),
},
},
i18n: {
getters: {
locale: () => 'en',
},
},
})
const user = factories.makeCurrentUser({ mailVerified: false })
const verificationWarningDatastore = createDatastore({
auth: {
getters: {
user: () => user,
failedEmailDeliveries: () => [],
},
},
users: {
getters: {
resendVerificationCodeStatus: () => statusMocks.default(),
resendVerificationCodeSuccess: () => false,
},
},
})
const failedEmailDeliveriesDatastore = createDatastore({
auth: {
getters: {
user: () => factories.makeCurrentUser({ mailVerified: true }),
failedEmailDeliveries: () => [{
subject: 'Your verification code',
event: '550',
reason: 'Unknown address',
createdAt: new Date(),
}],
},
},
users: {
getters: {
resendVerificationCodeStatus: () => statusMocks.default(),
resendVerificationCodeSuccess: () => false,
},
},
})
storiesOf('Settings Page', module)
.add('Default', () => defaults({
render (h) {
return h(Settings)
},
store: datastore,
}))
.add('verification warning', () => defaults({
render (h) {
return h(VerificationWarning)
},
store: verificationWarningDatastore,
}))
.add('failed email deliveries', () => defaults({
render (h) {
return h(VerificationWarning)
},
store: failedEmailDeliveriesDatastore,
}))