Tests that the hasElopage flag is changed.

This commit is contained in:
elweyn 2021-10-12 12:46:57 +02:00
parent fb93b39a19
commit f7d696eaca

View File

@ -12,6 +12,7 @@ const {
newsletterState, newsletterState,
publisherId, publisherId,
community, community,
hasElopage,
} = mutations } = mutations
const { login, logout } = actions const { login, logout } = actions
@ -114,6 +115,14 @@ describe('Vuex store', () => {
}) })
}) })
}) })
describe('hasElopage', () => {
it('sets the state of hasElopage', () => {
const state = { hasElopage: false }
hasElopage(state, true)
expect(state.hasElopage).toBeTruthy()
})
})
}) })
describe('actions', () => { describe('actions', () => {
@ -131,11 +140,12 @@ describe('Vuex store', () => {
klickTipp: { klickTipp: {
newsletterState: true, newsletterState: true,
}, },
hasElopage: false,
} }
it('calls eight commits', () => { it('calls nine commits', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenCalledTimes(8) expect(commit).toHaveBeenCalledTimes(9)
}) })
it('commits email', () => { it('commits email', () => {
@ -177,15 +187,20 @@ describe('Vuex store', () => {
login({ commit, state }, commitedData) login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', true) expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', true)
}) })
it('commits hasElopage', () => {
login({ commit, state }, commitedData)
expect(commit).toHaveBeenNthCalledWith(9, 'hasElopage', false)
})
}) })
describe('logout', () => { describe('logout', () => {
const commit = jest.fn() const commit = jest.fn()
const state = {} const state = {}
it('calls eight commits', () => { it('calls nine commits', () => {
logout({ commit, state }) logout({ commit, state })
expect(commit).toHaveBeenCalledTimes(8) expect(commit).toHaveBeenCalledTimes(9)
}) })
it('commits token', () => { it('commits token', () => {
@ -228,6 +243,11 @@ describe('Vuex store', () => {
expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', null) expect(commit).toHaveBeenNthCalledWith(8, 'newsletterState', null)
}) })
it('commits hasElopage', () => {
logout({ commit, state })
expect(commit).toHaveBeenNthCalledWith(9, 'hasElopage', false)
})
// how to get this working? // how to get this working?
it.skip('calls localStorage.clear()', () => { it.skip('calls localStorage.clear()', () => {
const clearStorageMock = jest.fn() const clearStorageMock = jest.fn()