@@ -19,39 +19,39 @@ describe('AccountDrawer', () => {
1919 }
2020 } )
2121
22- // it('AddMode', async () => {
23- // const email = 'test@protonmail.com'
24- // registerEndpoint(`user/get-by-email/${email}/`, () => {
25- // throw createError({ statusCode: 404 })
26- // })
27-
28- // const wrapper = await lpiMount(AccountDrawer, { props: defaultProps })
29- // expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(true)
30- // expect(wrapper.findComponent(AccountLayout).exists()).toBe(false)
31- // })
22+ it ( 'AddMode' , async ( ) => {
23+ const email = 'test@protonmail.com'
24+ registerEndpoint ( `user/get-by-email/${ email } /` , ( ) => {
25+ throw createError ( { statusCode : 404 } )
26+ } )
27+
28+ const wrapper = await lpiMount ( AccountDrawer , { props : defaultProps } )
29+ expect ( wrapper . findComponent ( ExistingAccountChecker ) . exists ( ) ) . toBe ( true )
30+ expect ( wrapper . findComponent ( AccountLayout ) . exists ( ) ) . toBe ( false )
31+ } )
3232
33- // it('AddMode email not exists', async () => {
34- // const email = 'test@protonmail.com'
35- // registerEndpoint(`user/get-by-email/${email}/`, () => {
36- // throw createError({ statusCode: 404 })
37- // })
33+ it ( 'AddMode email not exists' , async ( ) => {
34+ const email = 'test@protonmail.com'
35+ registerEndpoint ( `user/get-by-email/${ email } /` , ( ) => {
36+ throw createError ( { statusCode : 404 } )
37+ } )
3838
39- // const wrapper = await lpiMount(AccountDrawer, { props: defaultProps })
39+ const wrapper = await lpiMount ( AccountDrawer , { props : defaultProps } )
4040
41- // const input = wrapper.get<HTMLInputElement>('input[type="email"]')
42- // await input.setValue(email)
41+ const input = wrapper . get < HTMLInputElement > ( 'input[type="email"]' )
42+ await input . setValue ( email )
4343
44- // const confirm = wrapper.get<HTMLButtonElement>('[data-test="confirm-button"]')
45- // await confirm.element.click()
44+ const confirm = wrapper . get < HTMLButtonElement > ( '[data-test="confirm-button"]' )
45+ await confirm . element . click ( )
4646
47- // await flushPromises()
47+ await flushPromises ( )
4848
49- // expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
50- // expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
49+ expect ( wrapper . findComponent ( ExistingAccountChecker ) . exists ( ) ) . toBe ( false )
50+ expect ( wrapper . findComponent ( AccountLayout ) . exists ( ) ) . toBe ( true )
5151
52- // // email not exists so create user
53- // expect(wrapper.findComponent(AccountLayout).text()).contain('Create an account')
54- // })
52+ // email not exists so create user
53+ expect ( wrapper . findComponent ( AccountLayout ) . text ( ) ) . contain ( 'Create an account' )
54+ } )
5555
5656 it ( 'AddMode email exists' , async ( ) => {
5757 const props = {
@@ -73,34 +73,34 @@ describe('AccountDrawer', () => {
7373 await confirm . element . click ( )
7474
7575 await flushPromises ( )
76- // await flushPromises()
76+ await flushPromises ( )
7777
78- // expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
79- // expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
78+ expect ( wrapper . findComponent ( ExistingAccountChecker ) . exists ( ) ) . toBe ( false )
79+ expect ( wrapper . findComponent ( AccountLayout ) . exists ( ) ) . toBe ( true )
8080
81- // // email exists so update/add account
82- // expect(wrapper.findComponent(AccountLayout).text()).contain('Add an account')
81+ // email exists so update/add account
82+ expect ( wrapper . findComponent ( AccountLayout ) . text ( ) ) . contain ( 'Add an account' )
8383 } )
8484
85- // it('inviteMode', async () => {
86- // const props = {
87- // ...defaultProps,
88- // isAddMode: false,
89- // isInviteMode: true,
90- // selectedUser: UserFactory.generate(),
91- // }
92- // const organization = OrganizationOutputFactory.generate()
93- // registerEndpoint(`user/${props.selectedUser.id}/`, () => props.selectedUser)
94- // registerEndpoint(`organization/`, () => ({ results: [organization] }))
95- // const email = props.selectedUser.email
96- // registerEndpoint(`user/get-by-email/${email}/`, () => {
97- // throw createError({ statusCode: 404 })
98- // })
99-
100- // const wrapper = await lpiMount(AccountDrawer, {
101- // props,
102- // })
103- // expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
104- // expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
105- // })
85+ it ( 'inviteMode' , async ( ) => {
86+ const props = {
87+ ...defaultProps ,
88+ isAddMode : false ,
89+ isInviteMode : true ,
90+ selectedUser : UserFactory . generate ( ) ,
91+ }
92+ const organization = OrganizationOutputFactory . generate ( )
93+ registerEndpoint ( `user/${ props . selectedUser . id } /` , ( ) => props . selectedUser )
94+ registerEndpoint ( `organization/` , ( ) => ( { results : [ organization ] } ) )
95+ const email = props . selectedUser . email
96+ registerEndpoint ( `user/get-by-email/${ email } /` , ( ) => {
97+ throw createError ( { statusCode : 404 } )
98+ } )
99+
100+ const wrapper = await lpiMount ( AccountDrawer , {
101+ props,
102+ } )
103+ expect ( wrapper . findComponent ( ExistingAccountChecker ) . exists ( ) ) . toBe ( false )
104+ expect ( wrapper . findComponent ( AccountLayout ) . exists ( ) ) . toBe ( true )
105+ } )
106106} )
0 commit comments