diff --git a/spec/integration/store/GlobalHeader.spec.js b/spec/integration/store/GlobalHeader.spec.js index 60f2c254..38f6e917 100644 --- a/spec/integration/store/GlobalHeader.spec.js +++ b/spec/integration/store/GlobalHeader.spec.js @@ -3,17 +3,21 @@ import Vuex from 'vuex' import { ipcMain } from '~/spec/mock/electron' import GlobalHeader from '~/src/renderer/store/GlobalHeader' -const state = { - accounts: [], - changing: false, - hide: false +const state = () => { + return { + accounts: [], + changing: false, + hide: false + } } -const initState = { - namespaced: true, - state: state, - actions: GlobalHeader.actions, - mutations: GlobalHeader.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: GlobalHeader.actions, + mutations: GlobalHeader.mutations + } } const routerState = { @@ -34,7 +38,7 @@ describe('GlobalHeader', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - GlobalHeader: initState, + GlobalHeader: initStore(), route: routerState } }) @@ -90,8 +94,8 @@ describe('GlobalHeader', () => { }) }) it('should be switched', async () => { - await store.dispatch('GlobalHeader/switchHide', true) - expect(store.state.GlobalHeader.hide).toEqual(true) + const hide = await store.dispatch('GlobalHeader/switchHide', true) + expect(hide).toEqual(true) }) }) }) diff --git a/spec/integration/store/Preferences/Appearance.spec.js b/spec/integration/store/Preferences/Appearance.spec.js index 9f7f40f4..bd7637e8 100644 --- a/spec/integration/store/Preferences/Appearance.spec.js +++ b/spec/integration/store/Preferences/Appearance.spec.js @@ -8,23 +8,27 @@ import DefaultFonts from '@/utils/fonts' import Appearance from '@/store/Preferences/Appearance' import { ipcMain } from '~/spec/mock/electron' -const state = { - appearance: { - theme: Theme.Light.key, - fontSize: 14, - displayNameStyle: DisplayStyle.DisplayNameAndUsername.value, - timeFormat: TimeFormat.Absolute.value, - customThemeColor: LightTheme, - font: DefaultFonts[0] - }, - fonts: [] +const state = () => { + return { + appearance: { + theme: Theme.Light.key, + fontSize: 14, + displayNameStyle: DisplayStyle.DisplayNameAndUsername.value, + timeFormat: TimeFormat.Absolute.value, + customThemeColor: LightTheme, + font: DefaultFonts[0] + }, + fonts: [] + } } -const Preferences = { - namespaced: true, - state: state, - actions: Appearance.actions, - mutations: Appearance.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: Appearance.actions, + mutations: Appearance.mutations + } } const App = { @@ -43,8 +47,8 @@ describe('Preferences/Appearance', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - Preferences, - App + Preferences: initStore(), + App: App } }) ipcMain.once('update-preferences', (event, config) => { diff --git a/spec/integration/store/Preferences/Language.spec.js b/spec/integration/store/Preferences/Language.spec.js index 9ad2e1ec..4b5ace76 100644 --- a/spec/integration/store/Preferences/Language.spec.js +++ b/spec/integration/store/Preferences/Language.spec.js @@ -4,17 +4,21 @@ import { ipcMain } from '~/spec/mock/electron' import Language from '@/store/Preferences/Language' import DefaultLanguage from '~/src/constants/language' -const state = { - language: { - language: DefaultLanguage.en.key +const state = () => { + return { + language: { + language: DefaultLanguage.en.key + } } } -const initState = { - namespaced: true, - state: state, - actions: Language.actions, - mutations: Language.mutations +const initStore = () => { + return { + namespaced: true, + state: state, + actions: Language.actions, + mutations: Language.mutations + } } describe('Preferences/Language', () => { @@ -26,7 +30,7 @@ describe('Preferences/Language', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - Language: initState + Language: initStore() } }) }) diff --git a/spec/integration/store/Preferences/Notification.spec.js b/spec/integration/store/Preferences/Notification.spec.js index 860e5efd..5386d49e 100644 --- a/spec/integration/store/Preferences/Notification.spec.js +++ b/spec/integration/store/Preferences/Notification.spec.js @@ -3,22 +3,26 @@ import Vuex from 'vuex' import { ipcMain } from '~/spec/mock/electron' import Notification from '@/store/Preferences/Notification' -const state = { - notification: { - notify: { - reply: true, - reblog: true, - favourite: true, - follow: true +const state = () => { + return { + notification: { + notify: { + reply: true, + reblog: true, + favourite: true, + follow: true + } } } } -const initState = { - namespaced: true, - state: state, - actions: Notification.actions, - mutations: Notification.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: Notification.actions, + mutations: Notification.mutations + } } const App = { @@ -37,7 +41,7 @@ describe('Preferences/Notification', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - Notification: initState, + Notification: initStore(), App: App } }) diff --git a/spec/integration/store/TimelineSpace/Contents/Home.spec.js b/spec/integration/store/TimelineSpace/Contents/Home.spec.js index ddf82c0e..adf9c6c7 100644 --- a/spec/integration/store/TimelineSpace/Contents/Home.spec.js +++ b/spec/integration/store/TimelineSpace/Contents/Home.spec.js @@ -6,21 +6,25 @@ import Home from '~/src/renderer/store/TimelineSpace/Contents/Home' jest.genMockFromModule('megalodon') jest.mock('megalodon') -const state = { - lazyLoading: false, - heading: true, - timeline: [], - unreadTimeline: [], - filter: '', - showReblogs: true, - showReplies: true +const state = () => { + return { + lazyLoading: false, + heading: true, + timeline: [], + unreadTimeline: [], + filter: '', + showReblogs: true, + showReplies: true + } } -const initState = { - namespaced: true, - state: state, - actions: Home.actions, - mutations: Home.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: Home.actions, + mutations: Home.mutations + } } const timelineState = { @@ -42,7 +46,7 @@ describe('Home', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - Home: initState, + Home: initStore(), TimelineSpace: timelineState } }) @@ -102,8 +106,6 @@ describe('Home', () => { await store.dispatch('Home/lazyFetchTimeline', { id: 20 }) expect(store.state.Home.lazyLoading).toEqual(false) expect(store.state.Home.timeline).toEqual([ - { id: 1 }, - { id: 2 }, { id: 19 }, { id: 18 } ]) diff --git a/spec/integration/store/TimelineSpace/HeaderMenu.spec.js b/spec/integration/store/TimelineSpace/HeaderMenu.spec.js index d14bb108..f2c3b536 100644 --- a/spec/integration/store/TimelineSpace/HeaderMenu.spec.js +++ b/spec/integration/store/TimelineSpace/HeaderMenu.spec.js @@ -6,16 +6,20 @@ import HeaderMenu from '~/src/renderer/store/TimelineSpace/HeaderMenu' jest.genMockFromModule('megalodon') jest.mock('megalodon') -const state = { - title: 'Home', - reload: false +const state = () => { + return { + title: 'Home', + reload: false + } } -const initState = { - namespaced: true, - state: state, - actions: HeaderMenu.actions, - mutations: HeaderMenu.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: HeaderMenu.actions, + mutations: HeaderMenu.mutations + } } const timelineState = { @@ -37,7 +41,7 @@ describe('HeaderMenu', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - HeaderMenu: initState, + HeaderMenu: initStore(), TimelineSpace: timelineState } }) diff --git a/spec/integration/store/TimelineSpace/Modals/Jump.spec.js b/spec/integration/store/TimelineSpace/Modals/Jump.spec.js index 1ecf5722..37974cfd 100644 --- a/spec/integration/store/TimelineSpace/Modals/Jump.spec.js +++ b/spec/integration/store/TimelineSpace/Modals/Jump.spec.js @@ -4,56 +4,59 @@ import i18n from '~/src/config/i18n' import router from '@/router' import Jump from '~/src/renderer/store/TimelineSpace/Modals/Jump' -const state = { - modalOpen: true, - channel: '', - defaultChannelList: [ - { +const state = () => { + return { + modalOpen: true, + channel: '', + defaultChannelList: [ + { + name: i18n.t('side_menu.home'), + path: 'home' + }, + { + name: i18n.t('side_menu.notification'), + path: 'notifications' + }, + { + name: i18n.t('side_menu.favourite'), + path: 'favourites' + }, + { + name: i18n.t('side_menu.local'), + path: 'local' + }, + { + name: i18n.t('side_menu.public'), + path: 'public' + }, + { + name: i18n.t('side_menu.hashtag'), + path: 'hashtag' + }, + { + name: i18n.t('side_menu.search'), + path: 'search' + }, + { + name: i18n.t('side_menu.direct'), + path: 'direct-messages' + } + ], + listChannelList: [], + tagChannelList: [], + selectedChannel: { name: i18n.t('side_menu.home'), path: 'home' - }, - { - name: i18n.t('side_menu.notification'), - path: 'notifications' - }, - { - name: i18n.t('side_menu.favourite'), - path: 'favourites' - }, - { - name: i18n.t('side_menu.local'), - path: 'local' - }, - { - name: i18n.t('side_menu.public'), - path: 'public' - }, - { - name: i18n.t('side_menu.hashtag'), - path: 'hashtag' - }, - { - name: i18n.t('side_menu.search'), - path: 'search' - }, - { - name: i18n.t('side_menu.direct'), - path: 'direct-messages' } - ], - listChannelList: [], - tagChannelList: [], - selectedChannel: { - name: i18n.t('side_menu.home'), - path: 'home' } } - -const initState = { - namespaced: true, - state: state, - actions: Jump.actions, - mutations: Jump.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: Jump.actions, + mutations: Jump.mutations + } } const timelineState = { @@ -74,7 +77,7 @@ describe('Jump', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - Jump: initState, + Jump: initStore(), TimelineSpace: timelineState } }) diff --git a/spec/integration/store/TimelineSpace/SideMenu.spec.js b/spec/integration/store/TimelineSpace/SideMenu.spec.js index 1a1280a6..916d75a8 100644 --- a/spec/integration/store/TimelineSpace/SideMenu.spec.js +++ b/spec/integration/store/TimelineSpace/SideMenu.spec.js @@ -7,22 +7,26 @@ import SideMenu from '~/src/renderer/store/TimelineSpace/SideMenu' jest.genMockFromModule('megalodon') jest.mock('megalodon') -const state = { - unreadHomeTimeline: false, - unreadNotifications: false, - unreadLocalTimeline: false, - unreadDirectMessagesTimeline: false, - unreadPublicTimeline: false, - lists: [], - tags: [], - collapse: false +const state = () => { + return { + unreadHomeTimeline: false, + unreadNotifications: false, + unreadLocalTimeline: false, + unreadDirectMessagesTimeline: false, + unreadPublicTimeline: false, + lists: [], + tags: [], + collapse: false + } } -const initState = { - namespaced: true, - state: state, - actions: SideMenu.actions, - mutations: SideMenu.mutations +const initStore = () => { + return { + namespaced: true, + state: state(), + actions: SideMenu.actions, + mutations: SideMenu.mutations + } } describe('SideMenu', () => { @@ -34,7 +38,7 @@ describe('SideMenu', () => { localVue.use(Vuex) store = new Vuex.Store({ modules: { - SideMenu: initState + SideMenu: initStore() } }) Mastodon.mockClear()