mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
createUser as Mutation
This commit is contained in:
parent
c401344193
commit
5ded9f60be
@ -66,8 +66,8 @@ export class UserResolver {
|
|||||||
return 'success'
|
return 'success'
|
||||||
}
|
}
|
||||||
|
|
||||||
@Query(() => String)
|
@Mutation(() => String)
|
||||||
async create(
|
async createUser(
|
||||||
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
|
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const payload = {
|
const payload = {
|
||||||
|
|||||||
@ -43,3 +43,21 @@ export const updateUserInfos = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const resgisterUser = gql`
|
||||||
|
mutation(
|
||||||
|
$firstName: String!
|
||||||
|
$lastName: String!
|
||||||
|
$email: String!
|
||||||
|
$password: String!
|
||||||
|
$language: String!
|
||||||
|
) {
|
||||||
|
createUser(
|
||||||
|
email: $email
|
||||||
|
firstName: $firstName
|
||||||
|
lastName: $lastName
|
||||||
|
password: $password
|
||||||
|
language: $language
|
||||||
|
)
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|||||||
@ -62,24 +62,6 @@ export const transactionsQuery = gql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const resgisterUserQuery = gql`
|
|
||||||
query(
|
|
||||||
$firstName: String!
|
|
||||||
$lastName: String!
|
|
||||||
$email: String!
|
|
||||||
$password: String!
|
|
||||||
$language: String!
|
|
||||||
) {
|
|
||||||
create(
|
|
||||||
email: $email
|
|
||||||
firstName: $firstName
|
|
||||||
lastName: $lastName
|
|
||||||
password: $password
|
|
||||||
language: $language
|
|
||||||
)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
export const sendCoins = gql`
|
export const sendCoins = gql`
|
||||||
query($email: String!, $amount: Float!, $memo: String!) {
|
query($email: String!, $amount: Float!, $memo: String!) {
|
||||||
sendCoins(email: $email, amount: $amount, memo: $memo)
|
sendCoins(email: $email, amount: $amount, memo: $memo)
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import Register from './Register'
|
|||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
const resgisterUserQueryMock = jest.fn()
|
const resgisterUserMutationMock = jest.fn()
|
||||||
const routerPushMock = jest.fn()
|
const routerPushMock = jest.fn()
|
||||||
|
|
||||||
describe('Register', () => {
|
describe('Register', () => {
|
||||||
@ -20,10 +20,11 @@ describe('Register', () => {
|
|||||||
push: routerPushMock,
|
push: routerPushMock,
|
||||||
},
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: resgisterUserQueryMock,
|
mutate: resgisterUserMutationMock,
|
||||||
},
|
},
|
||||||
$store: {
|
$store: {
|
||||||
state: {
|
state: {
|
||||||
|
email: 'peter@lustig.de',
|
||||||
language: null,
|
language: null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -192,7 +193,7 @@ describe('Register', () => {
|
|||||||
|
|
||||||
describe('server sends back error', () => {
|
describe('server sends back error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
resgisterUserQueryMock.mockRejectedValue({ message: 'Ouch!' })
|
resgisterUserMutationMock.mockRejectedValue({ message: 'Ouch!' })
|
||||||
await wrapper.find('form').trigger('submit')
|
await wrapper.find('form').trigger('submit')
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
})
|
})
|
||||||
@ -217,7 +218,7 @@ describe('Register', () => {
|
|||||||
|
|
||||||
describe('server sends back success', () => {
|
describe('server sends back success', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
resgisterUserQueryMock.mockResolvedValue({
|
resgisterUserMutationMock.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
create: 'success',
|
create: 'success',
|
||||||
},
|
},
|
||||||
@ -227,7 +228,7 @@ describe('Register', () => {
|
|||||||
it('routes to "/thx/register"', async () => {
|
it('routes to "/thx/register"', async () => {
|
||||||
await wrapper.find('form').trigger('submit')
|
await wrapper.find('form').trigger('submit')
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
expect(resgisterUserQueryMock).toBeCalledWith(
|
expect(resgisterUserMutationMock).toBeCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
variables: {
|
variables: {
|
||||||
email: 'max.mustermann@gradido.net',
|
email: 'max.mustermann@gradido.net',
|
||||||
|
|||||||
@ -141,7 +141,7 @@
|
|||||||
import InputEmail from '../../components/Inputs/InputEmail.vue'
|
import InputEmail from '../../components/Inputs/InputEmail.vue'
|
||||||
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
||||||
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
import LanguageSwitchSelect from '../../components/LanguageSwitchSelect.vue'
|
||||||
import { resgisterUserQuery } from '../../graphql/queries'
|
import { resgisterUser } from '../../graphql/mutations'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
components: { InputPasswordConfirmation, InputEmail, LanguageSwitchSelect },
|
||||||
@ -190,8 +190,8 @@ export default {
|
|||||||
},
|
},
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.query({
|
.mutate({
|
||||||
query: resgisterUserQuery,
|
mutation: resgisterUser,
|
||||||
variables: {
|
variables: {
|
||||||
email: this.form.email,
|
email: this.form.email,
|
||||||
firstName: this.form.firstname,
|
firstName: this.form.firstname,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user