mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Change the tests setup to the call of mutations instead of queries.
This commit is contained in:
parent
4461ff92a5
commit
98aca9ff52
@ -18,6 +18,7 @@ const apolloMock = jest.fn().mockResolvedValue({
|
|||||||
logout: 'success',
|
logout: 'success',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
const apolloQueryMock = jest.fn()
|
||||||
|
|
||||||
describe('DashboardLayout', () => {
|
describe('DashboardLayout', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
@ -40,7 +41,8 @@ describe('DashboardLayout', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: apolloMock,
|
mutate: apolloMock,
|
||||||
|
query: apolloQueryMock,
|
||||||
},
|
},
|
||||||
$store: {
|
$store: {
|
||||||
state: {
|
state: {
|
||||||
@ -142,7 +144,7 @@ describe('DashboardLayout', () => {
|
|||||||
|
|
||||||
describe('update transactions', () => {
|
describe('update transactions', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloMock.mockResolvedValue({
|
apolloQueryMock.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
transactionList: {
|
transactionList: {
|
||||||
balance: {
|
balance: {
|
||||||
@ -163,7 +165,7 @@ describe('DashboardLayout', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('calls the API', () => {
|
it('calls the API', () => {
|
||||||
expect(apolloMock).toBeCalledWith(
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
variables: {
|
variables: {
|
||||||
currentPage: 2,
|
currentPage: 2,
|
||||||
@ -201,7 +203,7 @@ describe('DashboardLayout', () => {
|
|||||||
|
|
||||||
describe('update transactions returns error', () => {
|
describe('update transactions returns error', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
apolloMock.mockRejectedValue({
|
apolloQueryMock.mockRejectedValue({
|
||||||
message: 'Ouch!',
|
message: 'Ouch!',
|
||||||
})
|
})
|
||||||
await wrapper
|
await wrapper
|
||||||
|
|||||||
@ -84,7 +84,6 @@ export default {
|
|||||||
this.$router.push('/login')
|
this.$router.push('/login')
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.log('TESTTEST')
|
|
||||||
this.$store.dispatch('logout')
|
this.$store.dispatch('logout')
|
||||||
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
|
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import Login from './Login'
|
|||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
const apolloQueryMock = jest.fn()
|
const apolloMutateMock = jest.fn()
|
||||||
const mockStoreDispach = jest.fn()
|
const mockStoreDispach = jest.fn()
|
||||||
const mockStoreCommit = jest.fn()
|
const mockStoreCommit = jest.fn()
|
||||||
const mockRouterPush = jest.fn()
|
const mockRouterPush = jest.fn()
|
||||||
@ -41,7 +41,7 @@ describe('Login', () => {
|
|||||||
params: {},
|
params: {},
|
||||||
},
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
query: apolloQueryMock,
|
mutate: apolloMutateMock,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ describe('Login', () => {
|
|||||||
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
|
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
|
||||||
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
|
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
apolloQueryMock.mockResolvedValue({
|
apolloMutateMock.mockResolvedValue({
|
||||||
data: {
|
data: {
|
||||||
login: 'token',
|
login: 'token',
|
||||||
},
|
},
|
||||||
@ -123,7 +123,7 @@ describe('Login', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('calls the API with the given data', () => {
|
it('calls the API with the given data', () => {
|
||||||
expect(apolloQueryMock).toBeCalledWith(
|
expect(apolloMutateMock).toBeCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
variables: {
|
variables: {
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
@ -175,7 +175,7 @@ describe('Login', () => {
|
|||||||
|
|
||||||
describe('login fails', () => {
|
describe('login fails', () => {
|
||||||
const createError = async (errorMessage) => {
|
const createError = async (errorMessage) => {
|
||||||
apolloQueryMock.mockRejectedValue({
|
apolloMutateMock.mockRejectedValue({
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
})
|
})
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user