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',
|
||||
},
|
||||
})
|
||||
const apolloQueryMock = jest.fn()
|
||||
|
||||
describe('DashboardLayout', () => {
|
||||
let wrapper
|
||||
@ -40,7 +41,8 @@ describe('DashboardLayout', () => {
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloMock,
|
||||
mutate: apolloMock,
|
||||
query: apolloQueryMock,
|
||||
},
|
||||
$store: {
|
||||
state: {
|
||||
@ -142,7 +144,7 @@ describe('DashboardLayout', () => {
|
||||
|
||||
describe('update transactions', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMock.mockResolvedValue({
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
transactionList: {
|
||||
balance: {
|
||||
@ -163,7 +165,7 @@ describe('DashboardLayout', () => {
|
||||
})
|
||||
|
||||
it('calls the API', () => {
|
||||
expect(apolloMock).toBeCalledWith(
|
||||
expect(apolloQueryMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
currentPage: 2,
|
||||
@ -201,7 +203,7 @@ describe('DashboardLayout', () => {
|
||||
|
||||
describe('update transactions returns error', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMock.mockRejectedValue({
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
message: 'Ouch!',
|
||||
})
|
||||
await wrapper
|
||||
|
||||
@ -84,7 +84,6 @@ export default {
|
||||
this.$router.push('/login')
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('TESTTEST')
|
||||
this.$store.dispatch('logout')
|
||||
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
|
||||
})
|
||||
|
||||
@ -5,7 +5,7 @@ import Login from './Login'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const apolloQueryMock = jest.fn()
|
||||
const apolloMutateMock = jest.fn()
|
||||
const mockStoreDispach = jest.fn()
|
||||
const mockStoreCommit = jest.fn()
|
||||
const mockRouterPush = jest.fn()
|
||||
@ -41,7 +41,7 @@ describe('Login', () => {
|
||||
params: {},
|
||||
},
|
||||
$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="form.password"]').setValue('1234')
|
||||
await flushPromises()
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
apolloMutateMock.mockResolvedValue({
|
||||
data: {
|
||||
login: 'token',
|
||||
},
|
||||
@ -123,7 +123,7 @@ describe('Login', () => {
|
||||
})
|
||||
|
||||
it('calls the API with the given data', () => {
|
||||
expect(apolloQueryMock).toBeCalledWith(
|
||||
expect(apolloMutateMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
email: 'user@example.org',
|
||||
@ -175,7 +175,7 @@ describe('Login', () => {
|
||||
|
||||
describe('login fails', () => {
|
||||
const createError = async (errorMessage) => {
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
apolloMutateMock.mockRejectedValue({
|
||||
message: errorMessage,
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user