mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix signup component and test
This commit is contained in:
parent
a5d4dc50a6
commit
a8cfdf8192
@ -58,7 +58,8 @@ describe('Signup', () => {
|
||||
|
||||
it('delivers email to backend', () => {
|
||||
const expected = expect.objectContaining({
|
||||
variables: { email: 'mAIL@exAMPLE.org', token: null },
|
||||
mutation: SignupMutation,
|
||||
variables: { email: 'mAIL@exAMPLE.org', inviteCode: null },
|
||||
})
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected)
|
||||
})
|
||||
@ -84,45 +85,5 @@ describe('Signup', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invitation code', () => {
|
||||
let action
|
||||
beforeEach(() => {
|
||||
propsData.token = '666777'
|
||||
action = async () => {
|
||||
wrapper = Wrapper()
|
||||
wrapper.find('input#email').setValue('mail@example.org')
|
||||
await wrapper.find('form').trigger('submit')
|
||||
await wrapper.html()
|
||||
}
|
||||
})
|
||||
|
||||
describe('submit', () => {
|
||||
it('delivers invitation token to backend', async () => {
|
||||
await action()
|
||||
const expected = expect.objectContaining({
|
||||
variables: { email: 'mail@example.org', token: '666777' },
|
||||
})
|
||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected)
|
||||
})
|
||||
|
||||
describe('in case a user account with the email already exists', () => {
|
||||
beforeEach(() => {
|
||||
mocks.$apollo.mutate = jest
|
||||
.fn()
|
||||
.mockRejectedValue(
|
||||
new Error('UserInputError: A user account with this email already exists.'),
|
||||
)
|
||||
})
|
||||
|
||||
it('explains the error', async () => {
|
||||
await action()
|
||||
expect(mocks.$t).toHaveBeenCalledWith(
|
||||
'components.registration.signup.form.errors.email-exists',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -119,7 +119,7 @@ export default {
|
||||
|
||||
try {
|
||||
const response = await this.$apollo.mutate({
|
||||
SignupMutation,
|
||||
mutation: SignupMutation,
|
||||
variables: { email, inviteCode: null },
|
||||
})
|
||||
this.data = response.data
|
||||
|
||||
@ -147,5 +147,47 @@ describe('Registration', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// Wolle copied from webapp/components/Registration/Signup.spec.js as testing template
|
||||
// describe('with invitation code', () => {
|
||||
// let action
|
||||
// beforeEach(() => {
|
||||
// propsData.token = '12345'
|
||||
// action = async () => {
|
||||
// wrapper = Wrapper()
|
||||
// wrapper.find('input#email').setValue('mail@example.org')
|
||||
// await wrapper.find('form').trigger('submit')
|
||||
// await wrapper.html()
|
||||
// }
|
||||
// })
|
||||
|
||||
// describe('submit', () => {
|
||||
// it('delivers invitation code to backend', async () => {
|
||||
// await action()
|
||||
// const expected = expect.objectContaining({
|
||||
// mutation: SignupMutation,
|
||||
// variables: { email: 'mail@example.org', inviteCode: '12345' },
|
||||
// })
|
||||
// expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expected)
|
||||
// })
|
||||
|
||||
// describe('in case a user account with the email already exists', () => {
|
||||
// beforeEach(() => {
|
||||
// mocks.$apollo.mutate = jest
|
||||
// .fn()
|
||||
// .mockRejectedValue(
|
||||
// new Error('UserInputError: A user account with this email already exists.'),
|
||||
// )
|
||||
// })
|
||||
|
||||
// it('explains the error', async () => {
|
||||
// await action()
|
||||
// expect(mocks.$t).toHaveBeenCalledWith(
|
||||
// 'components.registration.signup.form.errors.email-exists',
|
||||
// )
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
// })
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user