Fix tests
This commit is contained in:
parent
b1b3fd78f9
commit
895c298e0c
|
@ -134,7 +134,6 @@
|
|||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@typescript-eslint/typescript-estree": "^5.19.0",
|
||||
"@vue/compiler-sfc": "^3.2.31",
|
||||
"@vue/test-utils": "^2.0.0-rc.20",
|
||||
"ajv": "^8.11.0",
|
||||
"all-object-keys": "^2.2.0",
|
||||
"assert": "^2.0.0",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import App from '@/store/App'
|
||||
import DisplayStyle from '~/src/constants/displayStyle'
|
||||
|
@ -9,7 +8,8 @@ import TimeFormat from '~/src/constants/timeFormat'
|
|||
import Language from '~/src/constants/language'
|
||||
import DefaultFonts from '@/utils/fonts'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const state = () => {
|
||||
return {
|
||||
|
@ -41,13 +41,10 @@ const initStore = () => {
|
|||
}
|
||||
|
||||
describe('App', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
App: initStore()
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import GlobalHeader, { GlobalHeaderState } from '~/src/renderer/store/GlobalHeader'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const state = (): GlobalHeaderState => {
|
||||
return {
|
||||
|
@ -32,13 +32,10 @@ const routerState = {
|
|||
}
|
||||
|
||||
describe('GlobalHeader', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
GlobalHeader: initStore(),
|
||||
route: routerState
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import Login, { LoginState } from '@/store/Login'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
|
@ -36,13 +36,10 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Login', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Login: initStore(),
|
||||
App: appState
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import Account, { AccountState } from '@/store/Preferences/Account'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const account: LocalAccount = {
|
||||
_id: 'sample',
|
||||
|
@ -36,16 +36,20 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const preferencesStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Account: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
describe('Account', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Account: initStore()
|
||||
Preferences: preferencesStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -56,7 +60,7 @@ describe('Account', () => {
|
|||
throw new Error()
|
||||
})
|
||||
|
||||
await store.dispatch('Account/loadAccounts').catch((err: Error) => {
|
||||
await store.dispatch('Preferences/Account/loadAccounts').catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('list-accounts')
|
||||
|
@ -65,8 +69,8 @@ describe('Account', () => {
|
|||
ipcMain.handle('list-accounts', () => {
|
||||
return [account]
|
||||
})
|
||||
await store.dispatch('Account/loadAccounts')
|
||||
expect(store.state.Account.accounts).toEqual([account])
|
||||
await store.dispatch('Preferences/Account/loadAccounts')
|
||||
expect(store.state.Preferences.Account.accounts).toEqual([account])
|
||||
ipcMain.removeHandler('list-accounts')
|
||||
})
|
||||
})
|
||||
|
@ -76,7 +80,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('remove-account', async () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Account/removeAccount', account).catch((err: Error) => {
|
||||
await store.dispatch('Preferences/Account/removeAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('remove-account')
|
||||
|
@ -85,7 +89,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('remove-account', () => {
|
||||
return true
|
||||
})
|
||||
const res = await store.dispatch('Account/removeAccount', account)
|
||||
const res = await store.dispatch('Preferences/Account/removeAccount', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('remove-account')
|
||||
})
|
||||
|
@ -96,7 +100,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('forward-account', async () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Account/forwardAccount', account).catch((err: Error) => {
|
||||
await store.dispatch('Preferences/Account/forwardAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('forward-account')
|
||||
|
@ -105,7 +109,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('forward-account', () => {
|
||||
return {}
|
||||
})
|
||||
const res = await store.dispatch('Account/forwardAccount', account)
|
||||
const res = await store.dispatch('Preferences/Account/forwardAccount', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('forward-account')
|
||||
})
|
||||
|
@ -116,7 +120,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('backward-account', () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Account/backwardAccount', account).catch((err: Error) => {
|
||||
await store.dispatch('Preferences/Account/backwardAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('backward-account')
|
||||
|
@ -125,7 +129,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('backward-account', () => {
|
||||
return {}
|
||||
})
|
||||
const res = await store.dispatch('Account/backwardAccount', account)
|
||||
const res = await store.dispatch('Preferences/Account/backwardAccount', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('backward-account')
|
||||
})
|
||||
|
@ -136,7 +140,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('remove-all-accounts', () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Account/removeAllAccounts', account).catch((err: Error) => {
|
||||
await store.dispatch('Preferences/Account/removeAllAccounts', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('remove-all-accounts')
|
||||
|
@ -145,7 +149,7 @@ describe('Account', () => {
|
|||
ipcMain.handle('remove-all-accounts', () => {
|
||||
return {}
|
||||
})
|
||||
const res = await store.dispatch('Account/removeAllAccounts', account)
|
||||
const res = await store.dispatch('Preferences/Account/removeAllAccounts', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('remove-all-accounts')
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { IpcMainInvokeEvent } from 'electron'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Theme from '~/src/constants/theme'
|
||||
import DisplayStyle from '~/src/constants/displayStyle'
|
||||
import TimeFormat from '~/src/constants/timeFormat'
|
||||
|
@ -9,7 +8,8 @@ import DefaultFonts from '@/utils/fonts'
|
|||
import Appearance, { AppearanceState } from '@/store/Preferences/Appearance'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const state = (): AppearanceState => {
|
||||
return {
|
||||
|
@ -35,6 +35,13 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const preferencesStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Appearance: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const App = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
|
@ -43,15 +50,12 @@ const App = {
|
|||
}
|
||||
|
||||
describe('Preferences/Appearance', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Preferences: initStore(),
|
||||
Preferences: preferencesStore(),
|
||||
App: App
|
||||
}
|
||||
})
|
||||
|
@ -73,9 +77,9 @@ describe('Preferences/Appearance', () => {
|
|||
ipcMain.removeHandler('get-preferences')
|
||||
})
|
||||
it('should be loaded', async () => {
|
||||
await store.dispatch('Preferences/loadAppearance')
|
||||
expect(store.state.Preferences.appearance.theme).toEqual(Theme.Dark.key)
|
||||
expect(store.state.Preferences.appearance.fontSize).toEqual(15)
|
||||
await store.dispatch('Preferences/Appearance/loadAppearance')
|
||||
expect(store.state.Preferences.Appearance.appearance.theme).toEqual(Theme.Dark.key)
|
||||
expect(store.state.Preferences.Appearance.appearance.fontSize).toEqual(15)
|
||||
})
|
||||
})
|
||||
describe('loadFonts', () => {
|
||||
|
@ -88,8 +92,8 @@ describe('Preferences/Appearance', () => {
|
|||
ipcMain.removeHandler('list-fonts')
|
||||
})
|
||||
it('should be loaded', async () => {
|
||||
await store.dispatch('Preferences/loadFonts')
|
||||
expect(store.state.Preferences.fonts).toEqual([DefaultFonts[0], 'my-font'])
|
||||
await store.dispatch('Preferences/Appearance/loadFonts')
|
||||
expect(store.state.Preferences.Appearance.fonts).toEqual([DefaultFonts[0], 'my-font'])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -104,38 +108,38 @@ describe('Preferences/Appearance', () => {
|
|||
ipcMain.removeHandler('update-preferences')
|
||||
})
|
||||
it('updateTheme', async () => {
|
||||
await store.dispatch('Preferences/updateTheme', Theme.Dark.key)
|
||||
expect(store.state.Preferences.appearance.theme).toEqual(Theme.Dark.key)
|
||||
await store.dispatch('Preferences/Appearance/updateTheme', Theme.Dark.key)
|
||||
expect(store.state.Preferences.Appearance.appearance.theme).toEqual(Theme.Dark.key)
|
||||
expect(App.actions.loadPreferences).toBeCalled()
|
||||
})
|
||||
|
||||
it('updateFontSize', async () => {
|
||||
await store.dispatch('Preferences/updateFontSize', 15)
|
||||
expect(store.state.Preferences.appearance.fontSize).toEqual(15)
|
||||
await store.dispatch('Preferences/Appearance/updateFontSize', 15)
|
||||
expect(store.state.Preferences.Appearance.appearance.fontSize).toEqual(15)
|
||||
expect(App.actions.loadPreferences).toBeCalled()
|
||||
})
|
||||
|
||||
it('updateDisplayNameStyle', async () => {
|
||||
await store.dispatch('Preferences/updateDisplayNameStyle', DisplayStyle.DisplayName.value)
|
||||
expect(store.state.Preferences.appearance.displayNameStyle).toEqual(DisplayStyle.DisplayName.value)
|
||||
await store.dispatch('Preferences/Appearance/updateDisplayNameStyle', DisplayStyle.DisplayName.value)
|
||||
expect(store.state.Preferences.Appearance.appearance.displayNameStyle).toEqual(DisplayStyle.DisplayName.value)
|
||||
expect(App.actions.loadPreferences).toBeCalled()
|
||||
})
|
||||
|
||||
it('updateTimeFormat', async () => {
|
||||
await store.dispatch('Preferences/updateTimeFormat', TimeFormat.Relative.value)
|
||||
expect(store.state.Preferences.appearance.timeFormat).toEqual(TimeFormat.Relative.value)
|
||||
await store.dispatch('Preferences/Appearance/updateTimeFormat', TimeFormat.Relative.value)
|
||||
expect(store.state.Preferences.Appearance.appearance.timeFormat).toEqual(TimeFormat.Relative.value)
|
||||
expect(App.actions.loadPreferences).toBeCalled()
|
||||
})
|
||||
|
||||
it('updateCustomThemeColor', async () => {
|
||||
await store.dispatch('Preferences/updateCustomThemeColor', DarkTheme)
|
||||
expect(store.state.Preferences.appearance.customThemeColor).toEqual(DarkTheme)
|
||||
await store.dispatch('Preferences/Appearance/updateCustomThemeColor', DarkTheme)
|
||||
expect(store.state.Preferences.Appearance.appearance.customThemeColor).toEqual(DarkTheme)
|
||||
expect(App.actions.loadPreferences).toBeCalled()
|
||||
})
|
||||
|
||||
it('updateFont', async () => {
|
||||
await store.dispatch('Preferences/updateFont', DefaultFonts[1])
|
||||
expect(store.state.Preferences.appearance.font).toEqual(DefaultFonts[1])
|
||||
await store.dispatch('Preferences/Appearance/updateFont', DefaultFonts[1])
|
||||
expect(store.state.Preferences.Appearance.appearance.font).toEqual(DefaultFonts[1])
|
||||
expect(App.actions.loadPreferences).toBeCalled()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import General, { GeneralState } from '@/store/Preferences/General'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
import { IpcMainInvokeEvent } from 'electron'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const state = (): GeneralState => {
|
||||
return {
|
||||
|
@ -34,6 +34,13 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const preferencesStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
General: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const app = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
|
@ -44,15 +51,12 @@ const app = {
|
|||
}
|
||||
|
||||
describe('Preferences/General', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Preferences: initStore(),
|
||||
Preferences: preferencesStore(),
|
||||
App: app
|
||||
}
|
||||
})
|
||||
|
@ -75,10 +79,10 @@ describe('Preferences/General', () => {
|
|||
ipcMain.removeHandler('get-preferences')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Preferences/loadGeneral')
|
||||
expect(store.state.Preferences.general.sound.fav_rb).toEqual(false)
|
||||
expect(store.state.Preferences.general.sound.toot).toEqual(false)
|
||||
expect(store.state.Preferences.loading).toEqual(false)
|
||||
await store.dispatch('Preferences/General/loadGeneral')
|
||||
expect(store.state.Preferences.General.general.sound.fav_rb).toEqual(false)
|
||||
expect(store.state.Preferences.General.general.sound.toot).toEqual(false)
|
||||
expect(store.state.Preferences.General.loading).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -92,13 +96,13 @@ describe('Preferences/General', () => {
|
|||
ipcMain.removeHandler('update-preferences')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Preferences/updateSound', {
|
||||
await store.dispatch('Preferences/General/updateSound', {
|
||||
fav_rb: false,
|
||||
toot: false
|
||||
})
|
||||
expect(store.state.Preferences.general.sound.fav_rb).toEqual(false)
|
||||
expect(store.state.Preferences.general.sound.toot).toEqual(false)
|
||||
expect(store.state.Preferences.loading).toEqual(false)
|
||||
expect(store.state.Preferences.General.general.sound.fav_rb).toEqual(false)
|
||||
expect(store.state.Preferences.General.general.sound.toot).toEqual(false)
|
||||
expect(store.state.Preferences.General.loading).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -112,15 +116,15 @@ describe('Preferences/General', () => {
|
|||
ipcMain.removeHandler('update-preferences')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Preferences/updateTimeline', {
|
||||
await store.dispatch('Preferences/General/updateTimeline', {
|
||||
cw: true,
|
||||
nsfw: true,
|
||||
hideAllAttachments: true
|
||||
})
|
||||
expect(store.state.Preferences.general.timeline.cw).toEqual(true)
|
||||
expect(store.state.Preferences.general.timeline.nsfw).toEqual(true)
|
||||
expect(store.state.Preferences.general.timeline.hideAllAttachments).toEqual(true)
|
||||
expect(store.state.Preferences.loading).toEqual(false)
|
||||
expect(store.state.Preferences.General.general.timeline.cw).toEqual(true)
|
||||
expect(store.state.Preferences.General.general.timeline.nsfw).toEqual(true)
|
||||
expect(store.state.Preferences.General.general.timeline.hideAllAttachments).toEqual(true)
|
||||
expect(store.state.Preferences.General.loading).toEqual(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import Language, { LanguageState } from '@/store/Preferences/Language'
|
||||
import DefaultLanguage from '~/src/constants/language'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const state = (): LanguageState => {
|
||||
return {
|
||||
|
@ -27,16 +27,20 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const preferencesStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Language: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
describe('Preferences/Language', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Language: initStore()
|
||||
Preferences: preferencesStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -59,8 +63,8 @@ describe('Preferences/Language', () => {
|
|||
ipcMain.removeHandler('get-preferences')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Language/loadLanguage')
|
||||
expect(store.state.Language.language.language).toEqual(DefaultLanguage.ja.key)
|
||||
await store.dispatch('Preferences/Language/loadLanguage')
|
||||
expect(store.state.Preferences.Language.language.language).toEqual(DefaultLanguage.ja.key)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -74,8 +78,8 @@ describe('Preferences/Language', () => {
|
|||
ipcMain.removeHandler('change-language')
|
||||
})
|
||||
it('should be changed', async () => {
|
||||
await store.dispatch('Language/changeLanguage', DefaultLanguage.ja.key)
|
||||
expect(store.state.Language.language.language).toEqual(DefaultLanguage.ja.key)
|
||||
await store.dispatch('Preferences/Language/changeLanguage', DefaultLanguage.ja.key)
|
||||
expect(store.state.Preferences.Language.language.language).toEqual(DefaultLanguage.ja.key)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import Notification, { NotificationState } from '@/store/Preferences/Notification'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const state = (): NotificationState => {
|
||||
return {
|
||||
|
@ -32,6 +32,13 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const preferencesStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Notification: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const App = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
|
@ -40,15 +47,12 @@ const App = {
|
|||
}
|
||||
|
||||
describe('Preferences/Notification', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Notification: initStore(),
|
||||
Preferences: preferencesStore(),
|
||||
App: App
|
||||
}
|
||||
})
|
||||
|
@ -77,8 +81,8 @@ describe('Preferences/Notification', () => {
|
|||
ipcMain.removeHandler('get-preferences')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Notification/loadNotification')
|
||||
expect(store.state.Notification.notification).toEqual({
|
||||
await store.dispatch('Preferences/Notification/loadNotification')
|
||||
expect(store.state.Preferences.Notification.notification).toEqual({
|
||||
notify: {
|
||||
reply: false,
|
||||
reblog: false,
|
||||
|
@ -105,11 +109,11 @@ describe('Preferences/Notification', () => {
|
|||
ipcMain.removeHandler('update-preferences')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Notification/updateNotify', {
|
||||
await store.dispatch('Preferences/Notification/updateNotify', {
|
||||
reply: false,
|
||||
reblog: false
|
||||
})
|
||||
expect(store.state.Notification.notification).toEqual({
|
||||
expect(store.state.Preferences.Notification.notification).toEqual({
|
||||
notify: {
|
||||
reply: false,
|
||||
reblog: false,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { RootState } from '@/store'
|
||||
import { Entity, Response } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import TimelineSpace, { TimelineSpaceState, blankAccount } from '~/src/renderer/store/TimelineSpace'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const emacsEmoji: Entity.Emoji = {
|
||||
shortcode: 'emacs',
|
||||
|
@ -172,13 +172,10 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('TimelineSpace', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: initStore(),
|
||||
App: appState
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import DirectMessages, { DirectMessagesState } from '@/store/TimelineSpace/Contents/DirectMessages'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getConversationTimeline: () => {
|
||||
|
@ -149,7 +149,14 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
DirectMessages: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -157,8 +164,11 @@ const timelineState = {
|
|||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -168,16 +178,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
DirectMessages: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -185,9 +191,9 @@ describe('Home', () => {
|
|||
|
||||
describe('fetchTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('DirectMessages/fetchTimeline')
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/DirectMessages/fetchTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.DirectMessages.timeline).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.DirectMessages.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -215,9 +221,9 @@ describe('Home', () => {
|
|||
resolve(res)
|
||||
})
|
||||
}
|
||||
await store.dispatch('DirectMessages/lazyFetchTimeline', status1)
|
||||
expect(store.state.DirectMessages.lazyLoading).toEqual(false)
|
||||
expect(store.state.DirectMessages.timeline).toEqual([status1, status2])
|
||||
await store.dispatch('TimelineSpace/Contents/DirectMessages/lazyFetchTimeline', status1)
|
||||
expect(store.state.TimelineSpace.Contents.DirectMessages.lazyLoading).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Contents.DirectMessages.timeline).toEqual([status1, status2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Favourites, { FavouritesState } from '@/store/TimelineSpace/Contents/Favourites'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getFavourites: () => {
|
||||
|
@ -147,7 +147,14 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Favourites: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -155,8 +162,11 @@ const timelineState = {
|
|||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -166,16 +176,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Favourites', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Favourites: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -183,9 +189,9 @@ describe('Favourites', () => {
|
|||
|
||||
describe('fetchFavourites', () => {
|
||||
it('does not exist header', async () => {
|
||||
await store.dispatch('Favourites/fetchFavourites', localAccount)
|
||||
expect(store.state.Favourites.favourites).toEqual([status1])
|
||||
expect(store.state.Favourites.maxId).toEqual(null)
|
||||
await store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', localAccount)
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.favourites).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.maxId).toEqual(null)
|
||||
})
|
||||
|
||||
it('link is null', async () => {
|
||||
|
@ -202,9 +208,9 @@ describe('Favourites', () => {
|
|||
resolve(res)
|
||||
})
|
||||
}
|
||||
await store.dispatch('Favourites/fetchFavourites', localAccount)
|
||||
expect(store.state.Favourites.favourites).toEqual([status1])
|
||||
expect(store.state.Favourites.maxId).toEqual(null)
|
||||
await store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', localAccount)
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.favourites).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.maxId).toEqual(null)
|
||||
})
|
||||
|
||||
it('link exists in header', async () => {
|
||||
|
@ -222,9 +228,9 @@ describe('Favourites', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('Favourites/fetchFavourites', localAccount)
|
||||
expect(store.state.Favourites.favourites).toEqual([status1])
|
||||
expect(store.state.Favourites.maxId).toEqual('2')
|
||||
await store.dispatch('TimelineSpace/Contents/Favourites/fetchFavourites', localAccount)
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.favourites).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.maxId).toEqual('2')
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -240,7 +246,7 @@ describe('Favourites', () => {
|
|||
}
|
||||
})
|
||||
it('should not be updated', async () => {
|
||||
const res = await store.dispatch('Favourites/lazyFetchFavourites')
|
||||
const res = await store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites')
|
||||
expect(res).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
@ -256,7 +262,7 @@ describe('Favourites', () => {
|
|||
}
|
||||
})
|
||||
it('should not be updated', async () => {
|
||||
const res = await store.dispatch('Favourites/lazyFetchFavourites')
|
||||
const res = await store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites')
|
||||
expect(res).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
@ -286,9 +292,9 @@ describe('Favourites', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('Favourites/lazyFetchFavourites')
|
||||
expect(store.state.Favourites.favourites).toEqual([status1, status2])
|
||||
expect(store.state.Favourites.maxId).toEqual(null)
|
||||
await store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites')
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.favourites).toEqual([status1, status2])
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.maxId).toEqual(null)
|
||||
})
|
||||
|
||||
it('link exists in header', async () => {
|
||||
|
@ -306,9 +312,9 @@ describe('Favourites', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('Favourites/lazyFetchFavourites')
|
||||
expect(store.state.Favourites.favourites).toEqual([status1, status2])
|
||||
expect(store.state.Favourites.maxId).toEqual('3')
|
||||
await store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites')
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.favourites).toEqual([status1, status2])
|
||||
expect(store.state.TimelineSpace.Contents.Favourites.maxId).toEqual('3')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Entity, Response } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import FollowRequests, { FollowRequestsState } from '@/store/TimelineSpace/Contents/FollowRequests'
|
||||
import { SideMenuState } from '@/store/TimelineSpace/SideMenu'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getFollowRequests: () => {
|
||||
|
@ -110,19 +110,27 @@ const sideMenuState = (): SideMenuState => {
|
|||
}
|
||||
}
|
||||
|
||||
const sideMenuStore = {
|
||||
const sideMenuStore = () => ({
|
||||
namespaced: true,
|
||||
state: sideMenuState(),
|
||||
actions: {
|
||||
fetchFollowRequests: jest.fn()
|
||||
},
|
||||
mutations: {}
|
||||
}
|
||||
})
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
SideMenu: sideMenuStore
|
||||
FollowRequests: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
SideMenu: sideMenuStore(),
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
|
@ -131,7 +139,7 @@ const timelineState = {
|
|||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -141,16 +149,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
FollowRequests: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -158,8 +162,8 @@ describe('Home', () => {
|
|||
|
||||
describe('fetchRequests', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('FollowRequests/fetchRequests')
|
||||
expect(store.state.FollowRequests.requests).toEqual([account])
|
||||
await store.dispatch('TimelineSpace/Contents/FollowRequests/fetchRequests')
|
||||
expect(store.state.TimelineSpace.Contents.FollowRequests.requests).toEqual([account])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -184,8 +188,8 @@ describe('Home', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('FollowRequests/acceptRequest', account)
|
||||
expect(store.state.FollowRequests.requests).toEqual([])
|
||||
await store.dispatch('TimelineSpace/Contents/FollowRequests/acceptRequest', account)
|
||||
expect(store.state.TimelineSpace.Contents.FollowRequests.requests).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -210,8 +214,8 @@ describe('Home', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('FollowRequests/rejectRequest', account)
|
||||
expect(store.state.FollowRequests.requests).toEqual([])
|
||||
await store.dispatch('TimelineSpace/Contents/FollowRequests/rejectRequest', account)
|
||||
expect(store.state.TimelineSpace.Contents.FollowRequests.requests).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { IpcMainInvokeEvent } from 'electron'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import Vuex from 'vuex'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import List, { ListState } from '@/store/TimelineSpace/Contents/Hashtag/List'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const tag1: LocalTag = {
|
||||
tagName: 'tag1',
|
||||
|
@ -32,6 +32,20 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const hashtagStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
List: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Hashtag: hashtagStore()
|
||||
}
|
||||
})
|
||||
|
||||
const sideMenuStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
|
@ -39,24 +53,21 @@ const sideMenuStore = {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
SideMenu: sideMenuStore
|
||||
SideMenu: sideMenuStore,
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
describe('Hashtag/List', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
List: initStore(),
|
||||
TimelineSpace: timelineState
|
||||
TimelineSpace: timelineStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -69,8 +80,8 @@ describe('Hashtag/List', () => {
|
|||
afterEach(() => {
|
||||
ipcMain.removeHandler('list-hashtags')
|
||||
})
|
||||
await store.dispatch('List/listTags')
|
||||
expect(store.state.List.tags).toEqual([tag1, tag2])
|
||||
await store.dispatch('TimelineSpace/Contents/Hashtag/List/listTags')
|
||||
expect(store.state.TimelineSpace.Contents.Hashtag.List.tags).toEqual([tag1, tag2])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -79,7 +90,7 @@ describe('Hashtag/List', () => {
|
|||
ipcMain.handle('remove-hashtag', (_: IpcMainInvokeEvent, tag: LocalTag) => {
|
||||
expect(tag).toEqual(tag1)
|
||||
})
|
||||
await store.dispatch('List/removeTag', tag1)
|
||||
await store.dispatch('TimelineSpace/Contents/Hashtag/List/removeTag', tag1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Tag, { TagState } from '@/store/TimelineSpace/Contents/Hashtag/Tag'
|
||||
import { LoadPositionWithTag } from '@/types/loadPosition'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getTagTimeline: () => {
|
||||
|
@ -134,15 +134,32 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const hashtagStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Tag: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Hashtag: hashtagStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -152,16 +169,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Tag: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -169,9 +182,9 @@ describe('Home', () => {
|
|||
|
||||
describe('fetch', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('Tag/fetch', 'tag')
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', 'tag')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.Tag.timeline).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Hashtag.Tag.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -203,9 +216,9 @@ describe('Home', () => {
|
|||
status: status1,
|
||||
tag: 'tag'
|
||||
}
|
||||
await store.dispatch('Tag/lazyFetchTimeline', loadPositionWithTag)
|
||||
expect(store.state.Tag.lazyLoading).toEqual(false)
|
||||
expect(store.state.Tag.timeline).toEqual([status1, status2])
|
||||
await store.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', loadPositionWithTag)
|
||||
expect(store.state.TimelineSpace.Contents.Hashtag.Tag.lazyLoading).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Contents.Hashtag.Tag.timeline).toEqual([status1, status2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Home, { HomeState } from '@/store/TimelineSpace/Contents/Home'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getHomeTimeline: () => {
|
||||
|
@ -126,7 +126,7 @@ let state = (): HomeState => {
|
|||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
const homeStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
|
@ -135,7 +135,14 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Home: homeStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -148,8 +155,11 @@ const timelineState = {
|
|||
notifications: false
|
||||
}
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -159,16 +169,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Home: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -176,9 +182,9 @@ describe('Home', () => {
|
|||
|
||||
describe('fetchTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('Home/fetchTimeline')
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Home/fetchTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.Home.timeline).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Home.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -210,9 +216,9 @@ describe('Home', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('Home/lazyFetchTimeline', status1)
|
||||
expect(store.state.Home.lazyLoading).toEqual(false)
|
||||
expect(store.state.Home.timeline).toEqual([status1, status2])
|
||||
await store.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', status1)
|
||||
expect(store.state.TimelineSpace.Contents.Home.lazyLoading).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Contents.Home.timeline).toEqual([status1, status2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Edit, { EditState } from '@/store/TimelineSpace/Contents/Lists/Edit'
|
||||
import { RemoveAccountFromList } from '@/types/removeAccountFromList'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getAccountsInList: () => {
|
||||
|
@ -72,7 +72,21 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const listsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Edit: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Lists: listsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -80,8 +94,11 @@ const timelineState = {
|
|||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -91,16 +108,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Lists/Edit', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Edit: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -108,8 +121,8 @@ describe('Lists/Edit', () => {
|
|||
|
||||
describe('fetchMembers', () => {
|
||||
it('should get', async () => {
|
||||
await store.dispatch('Edit/fetchMembers', 'id')
|
||||
expect(store.state.Edit.members).toEqual([account])
|
||||
await store.dispatch('TimelineSpace/Contents/Lists/Edit/fetchMembers', 'id')
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Edit.members).toEqual([account])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -119,7 +132,7 @@ describe('Lists/Edit', () => {
|
|||
account: account,
|
||||
listId: 'id'
|
||||
}
|
||||
const res = await store.dispatch('Edit/removeAccount', removeFromList)
|
||||
const res = await store.dispatch('TimelineSpace/Contents/Lists/Edit/removeAccount', removeFromList)
|
||||
expect(res.data).toEqual({})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Index, { IndexState } from '@/store/TimelineSpace/Contents/Lists/Index'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getLists: () => {
|
||||
|
@ -54,7 +54,21 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const listsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Index: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Lists: listsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -62,8 +76,11 @@ const timelineState = {
|
|||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -73,16 +90,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Lists/Index', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Index: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -90,14 +103,14 @@ describe('Lists/Index', () => {
|
|||
|
||||
describe('fetchLists', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Index/fetchLists')
|
||||
expect(store.state.Index.lists).toEqual([list])
|
||||
await store.dispatch('TimelineSpace/Contents/Lists/Index/fetchLists')
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Index.lists).toEqual([list])
|
||||
})
|
||||
})
|
||||
|
||||
describe('createList', () => {
|
||||
it('should be created', async () => {
|
||||
const res: Entity.List = await store.dispatch('Index/createList', 'list1')
|
||||
const res: Entity.List = await store.dispatch('TimelineSpace/Contents/Lists/Index/createList', 'list1')
|
||||
expect(res.title).toEqual('list1')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Show, { ShowState } from '@/store/TimelineSpace/Contents/Lists/Show'
|
||||
import { LoadPositionWithList } from '@/types/loadPosition'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getListTimeline: () => {
|
||||
|
@ -136,15 +136,32 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const listsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Show: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Lists: listsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -154,16 +171,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Lists/Show', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Show: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -171,8 +184,8 @@ describe('Lists/Show', () => {
|
|||
|
||||
describe('fetchTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Show/fetchTimeline', '1')
|
||||
expect(store.state.Show.timeline).toEqual([status1])
|
||||
await store.dispatch('TimelineSpace/Contents/Lists/Show/fetchTimeline', '1')
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Show.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -204,9 +217,9 @@ describe('Lists/Show', () => {
|
|||
status: status1,
|
||||
list_id: '1'
|
||||
}
|
||||
await store.dispatch('Show/lazyFetchTimeline', loadPosition)
|
||||
expect(store.state.Show.timeline).toEqual([status1, status2])
|
||||
expect(store.state.Show.lazyLoading).toEqual(false)
|
||||
await store.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', loadPosition)
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Show.timeline).toEqual([status1, status2])
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Show.lazyLoading).toEqual(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Local, { LocalState } from '@/store/TimelineSpace/Contents/Local'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getLocalTimeline: () => {
|
||||
|
@ -133,15 +133,25 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Local: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -151,16 +161,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Local: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -168,9 +174,9 @@ describe('Home', () => {
|
|||
|
||||
describe('fetchLocalTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('Local/fetchLocalTimeline')
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.Local.timeline).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Local.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -199,9 +205,9 @@ describe('Home', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('Local/lazyFetchTimeline', status1)
|
||||
expect(store.state.Local.lazyLoading).toEqual(false)
|
||||
expect(store.state.Local.timeline).toEqual([status1, status2])
|
||||
await store.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', status1)
|
||||
expect(store.state.TimelineSpace.Contents.Local.lazyLoading).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Contents.Local.timeline).toEqual([status1, status2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { RootState } from '@/store'
|
||||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Mentions from '~/src/renderer/store/TimelineSpace/Contents/Mentions'
|
||||
|
||||
const mockClient = {
|
||||
|
@ -129,7 +129,15 @@ const initStore = () => {
|
|||
getters: Mentions.getters
|
||||
}
|
||||
}
|
||||
const timelineState = {
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Mentions: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -143,8 +151,11 @@ const timelineState = {
|
|||
mentions: false
|
||||
}
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -154,16 +165,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Mentions', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Mentions: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -171,8 +178,8 @@ describe('Mentions', () => {
|
|||
|
||||
describe('fetchMentions', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Mentions/fetchMentions')
|
||||
expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
|
||||
await store.dispatch('TimelineSpace/Contents/Mentions/fetchMentions')
|
||||
expect(store.state.TimelineSpace.Contents.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -189,7 +196,7 @@ describe('Mentions', () => {
|
|||
}
|
||||
})
|
||||
it('should not be updated', async () => {
|
||||
const result = await store.dispatch('Mentions/lazyFetchMentions', {})
|
||||
const result = await store.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', {})
|
||||
expect(result).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
@ -218,9 +225,9 @@ describe('Mentions', () => {
|
|||
})
|
||||
}
|
||||
|
||||
await store.dispatch('Mentions/lazyFetchMentions', { id: 1 })
|
||||
expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
|
||||
expect(store.state.Mentions.lazyLoading).toEqual(false)
|
||||
await store.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', { id: 1 })
|
||||
expect(store.state.TimelineSpace.Contents.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
|
||||
expect(store.state.TimelineSpace.Contents.Mentions.lazyLoading).toEqual(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -237,7 +244,7 @@ describe('Mentions', () => {
|
|||
}
|
||||
})
|
||||
it('should return only mentions', () => {
|
||||
const mentions = store.getters['Mentions/mentions']
|
||||
const mentions = store.getters['TimelineSpace/Contents/Mentions/mentions']
|
||||
expect(mentions).toEqual([mention])
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Notifications, { NotificationsState } from '@/store/TimelineSpace/Contents/Notifications'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getNotifications: () => {
|
||||
|
@ -209,7 +209,14 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Notifications: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -223,8 +230,11 @@ const timelineState = {
|
|||
mentions: false
|
||||
}
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -235,16 +245,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Notifications', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Notifications: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -252,9 +258,9 @@ describe('Notifications', () => {
|
|||
|
||||
describe('fetchNotifications', () => {
|
||||
it('should be updated', async () => {
|
||||
const response = await store.dispatch('Notifications/fetchNotifications')
|
||||
const response = await store.dispatch('TimelineSpace/Contents/Notifications/fetchNotifications')
|
||||
expect(response).toEqual([notification1])
|
||||
expect(store.state.Notifications.notifications).toEqual([notification1])
|
||||
expect(store.state.TimelineSpace.Contents.Notifications.notifications).toEqual([notification1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -281,9 +287,9 @@ describe('Notifications', () => {
|
|||
resolve(res)
|
||||
})
|
||||
}
|
||||
await store.dispatch('Notifications/lazyFetchNotifications', notification1)
|
||||
expect(store.state.Notifications.lazyLoading).toEqual(false)
|
||||
expect(store.state.Notifications.notifications).toEqual([notification1, notification2])
|
||||
await store.dispatch('TimelineSpace/Contents/Notifications/lazyFetchNotifications', notification1)
|
||||
expect(store.state.TimelineSpace.Contents.Notifications.lazyLoading).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Contents.Notifications.notifications).toEqual([notification1, notification2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Public, { PublicState } from '@/store/TimelineSpace/Contents/Public'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getPublicTimeline: () => {
|
||||
|
@ -133,15 +133,25 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Public: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -151,16 +161,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Public: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -168,9 +174,9 @@ describe('Home', () => {
|
|||
|
||||
describe('fetchPublicTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('Public/fetchPublicTimeline')
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Public/fetchPublicTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.Public.timeline).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Public.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -198,9 +204,9 @@ describe('Home', () => {
|
|||
resolve(res)
|
||||
})
|
||||
}
|
||||
await store.dispatch('Public/lazyFetchTimeline', status1)
|
||||
expect(store.state.Public.lazyLoading).toEqual(false)
|
||||
expect(store.state.Public.timeline).toEqual([status1, status2])
|
||||
await store.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', status1)
|
||||
expect(store.state.TimelineSpace.Contents.Public.lazyLoading).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Contents.Public.timeline).toEqual([status1, status2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import AccountStore, { AccountState } from '@/store/TimelineSpace/Contents/Search/Account'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
|
@ -60,19 +60,29 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const contentsStore = {
|
||||
const searchStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Account: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {
|
||||
changeLoading: jest.fn()
|
||||
},
|
||||
actions: {}
|
||||
}
|
||||
actions: {},
|
||||
modules: {
|
||||
Search: searchStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineState = {
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
|
@ -81,7 +91,7 @@ const timelineState = {
|
|||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -91,16 +101,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Search/Account', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Account: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -108,8 +114,8 @@ describe('Search/Account', () => {
|
|||
|
||||
describe('search', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Account/search', 'query')
|
||||
expect(store.state.Account.results).toEqual([account])
|
||||
await store.dispatch('TimelineSpace/Contents/Search/Account/search', 'query')
|
||||
expect(store.state.TimelineSpace.Contents.Search.Account.results).toEqual([account])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import TagStore, { TagState } from '@/store/TimelineSpace/Contents/Search/Tag'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const tag1: Entity.Tag = {
|
||||
name: 'tag1',
|
||||
|
@ -48,19 +48,29 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const contentsStore = {
|
||||
const searchStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Tag: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {
|
||||
changeLoading: jest.fn()
|
||||
},
|
||||
actions: {}
|
||||
}
|
||||
actions: {},
|
||||
modules: {
|
||||
Search: searchStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineState = {
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
|
@ -69,7 +79,8 @@ const timelineState = {
|
|||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
@ -78,16 +89,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Search/Tag', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Tag: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -95,8 +102,8 @@ describe('Search/Tag', () => {
|
|||
|
||||
describe('search', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Tag/search', 'query')
|
||||
expect(store.state.Tag.results).toEqual([tag1])
|
||||
await store.dispatch('TimelineSpace/Contents/Search/Tag/search', 'query')
|
||||
expect(store.state.TimelineSpace.Contents.Search.Tag.results).toEqual([tag1])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Toots, { TootsState } from '@/store/TimelineSpace/Contents/Search/Toots'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
search: () => {
|
||||
|
@ -100,19 +100,29 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const contentsStore = {
|
||||
const searchStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Toots: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {
|
||||
changeLoading: jest.fn()
|
||||
},
|
||||
actions: {}
|
||||
}
|
||||
actions: {},
|
||||
modules: {
|
||||
Search: searchStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineState = {
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
|
@ -121,7 +131,7 @@ const timelineState = {
|
|||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -131,16 +141,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('Search/Account', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Toots: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -148,8 +154,8 @@ describe('Search/Account', () => {
|
|||
|
||||
describe('search', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('Toots/search', 'query')
|
||||
expect(store.state.Toots.results).toEqual([status])
|
||||
await store.dispatch('TimelineSpace/Contents/Search/Toots/search', 'query')
|
||||
expect(store.state.TimelineSpace.Contents.Search.Toots.results).toEqual([status])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { RootState } from '@/store'
|
||||
import { Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import AccountProfile, { AccountProfileState } from '~/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile'
|
||||
|
||||
const state = (account: Entity.Account | null): AccountProfileState => {
|
||||
|
@ -12,7 +12,31 @@ const state = (account: Entity.Account | null): AccountProfileState => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineSpace = {
|
||||
const initStore = (account: Entity.Account | null) => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(account),
|
||||
actions: AccountProfile.actions,
|
||||
mutations: AccountProfile.mutations,
|
||||
getters: AccountProfile.getters
|
||||
}
|
||||
}
|
||||
|
||||
const sidebarStore = (account: Entity.Account | null) => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
AccountProfile: initStore(account)
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = (account: Entity.Account | null) => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
SideBar: sidebarStore(account)
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = (account: Entity.Account | null) => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -27,30 +51,19 @@ const timelineSpace = {
|
|||
avatar: null,
|
||||
order: 1
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore(account)
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = (account: Entity.Account | null) => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(account),
|
||||
actions: AccountProfile.actions,
|
||||
mutations: AccountProfile.mutations,
|
||||
getters: AccountProfile.getters
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
describe('AccountProfile', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
AccountProfile: initStore(null),
|
||||
TimelineSpace: timelineSpace
|
||||
TimelineSpace: timelineStore(null)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -79,15 +92,14 @@ describe('AccountProfile', () => {
|
|||
bot: false
|
||||
}
|
||||
beforeEach(() => {
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
AccountProfile: initStore(account),
|
||||
TimelineSpace: timelineSpace
|
||||
TimelineSpace: timelineStore(account)
|
||||
}
|
||||
})
|
||||
})
|
||||
it('should be matched', () => {
|
||||
expect(store.getters['AccountProfile/isOwnProfile']).toBeTruthy()
|
||||
expect(store.getters['TimelineSpace/Contents/SideBar/AccountProfile/isOwnProfile']).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -114,15 +126,14 @@ describe('AccountProfile', () => {
|
|||
bot: false
|
||||
}
|
||||
beforeEach(() => {
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
AccountProfile: initStore(account),
|
||||
TimelineSpace: timelineSpace
|
||||
TimelineSpace: timelineStore(account)
|
||||
}
|
||||
})
|
||||
})
|
||||
it('should be matched', () => {
|
||||
expect(store.getters['AccountProfile/isOwnProfile']).toBeFalsy()
|
||||
expect(store.getters['TimelineSpace/Contents/SideBar/AccountProfile/isOwnProfile']).toBeFalsy()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -149,15 +160,14 @@ describe('AccountProfile', () => {
|
|||
bot: false
|
||||
}
|
||||
beforeEach(() => {
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
AccountProfile: initStore(account),
|
||||
TimelineSpace: timelineSpace
|
||||
TimelineSpace: timelineStore(account)
|
||||
}
|
||||
})
|
||||
})
|
||||
it('should be matched', () => {
|
||||
expect(store.getters['AccountProfile/isOwnProfile']).toBeTruthy()
|
||||
expect(store.getters['TimelineSpace/Contents/SideBar/AccountProfile/isOwnProfile']).toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -184,15 +194,14 @@ describe('AccountProfile', () => {
|
|||
bot: false
|
||||
}
|
||||
beforeEach(() => {
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
AccountProfile: initStore(account),
|
||||
TimelineSpace: timelineSpace
|
||||
TimelineSpace: timelineStore(account)
|
||||
}
|
||||
})
|
||||
})
|
||||
it('should be matched', () => {
|
||||
expect(store.getters['AccountProfile/isOwnProfile']).toBeFalsy()
|
||||
expect(store.getters['TimelineSpace/Contents/SideBar/AccountProfile/isOwnProfile']).toBeFalsy()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { RootState } from '@/store'
|
||||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import HeaderMenu, { HeaderMenuState } from '~/src/renderer/store/TimelineSpace/HeaderMenu'
|
||||
|
||||
const list: Entity.List = {
|
||||
|
@ -45,7 +45,7 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
|
@ -53,8 +53,11 @@ const timelineState = {
|
|||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
HeaderMenu: initStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -64,16 +67,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('HeaderMenu', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
HeaderMenu: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -81,9 +80,9 @@ describe('HeaderMenu', () => {
|
|||
|
||||
describe('fetchLists', () => {
|
||||
it('should be updated', async () => {
|
||||
const l = await store.dispatch('HeaderMenu/fetchList', list.id)
|
||||
const l = await store.dispatch('TimelineSpace/HeaderMenu/fetchList', list.id)
|
||||
expect(l).toEqual(list)
|
||||
expect(store.state.HeaderMenu.title).toEqual(`#${list.title}`)
|
||||
expect(store.state.TimelineSpace.HeaderMenu.title).toEqual(`#${list.title}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import AddListMember, { AddListMemberState } from '@/store/TimelineSpace/Modals/AddListMember'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
searchAccount: () => {
|
||||
|
@ -73,15 +73,25 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const modalsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
AddListMember: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
_id: '0'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Modals: modalsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -91,16 +101,13 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('AddListMember', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
AddListMember: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -108,21 +115,21 @@ describe('AddListMember', () => {
|
|||
|
||||
describe('changeModal', () => {
|
||||
it('should change modal', () => {
|
||||
store.dispatch('AddListMember/changeModal', true)
|
||||
expect(store.state.AddListMember.modalOpen).toEqual(true)
|
||||
store.dispatch('TimelineSpace/Modals/AddListMember/changeModal', true)
|
||||
expect(store.state.TimelineSpace.Modals.AddListMember.modalOpen).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('search', () => {
|
||||
it('should be searched', async () => {
|
||||
await store.dispatch('AddListMember/search', 'akira')
|
||||
expect(store.state.AddListMember.accounts).toEqual([account])
|
||||
await store.dispatch('TimelineSpace/Modals/AddListMember/search', 'akira')
|
||||
expect(store.state.TimelineSpace.Modals.AddListMember.accounts).toEqual([account])
|
||||
})
|
||||
})
|
||||
|
||||
describe('add', () => {
|
||||
it('should be added a member to the list', async () => {
|
||||
const result = await store.dispatch('AddListMember/add', 'akira')
|
||||
const result = await store.dispatch('TimelineSpace/Modals/AddListMember/add', 'akira')
|
||||
expect(result).toEqual({})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import ImageViewer, { ImageViewerState } from '~/src/renderer/store/TimelineSpace/Modals/ImageViewer'
|
||||
|
||||
const state = (): ImageViewerState => {
|
||||
|
@ -21,16 +21,27 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const modalsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
ImageViewer: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Modals: modalsStore()
|
||||
}
|
||||
})
|
||||
|
||||
describe('ImageViewer', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
ImageViewer: initStore()
|
||||
TimelineSpace: timelineStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -38,46 +49,46 @@ describe('ImageViewer', () => {
|
|||
// Actions
|
||||
describe('openModal', () => {
|
||||
it('should be changed', () => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 1,
|
||||
mediaList: ['media1', 'media2']
|
||||
})
|
||||
expect(store.state.ImageViewer.modalOpen).toEqual(true)
|
||||
expect(store.state.ImageViewer.currentIndex).toEqual(1)
|
||||
expect(store.state.ImageViewer.mediaList).toEqual(['media1', 'media2'])
|
||||
expect(store.state.ImageViewer.loading).toEqual(true)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.modalOpen).toEqual(true)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.currentIndex).toEqual(1)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.mediaList).toEqual(['media1', 'media2'])
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.loading).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('closeModal', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 1,
|
||||
mediaList: ['media1', 'media2']
|
||||
})
|
||||
})
|
||||
it('should be changed', () => {
|
||||
store.dispatch('ImageViewer/closeModal')
|
||||
expect(store.state.ImageViewer.modalOpen).toEqual(false)
|
||||
expect(store.state.ImageViewer.currentIndex).toEqual(-1)
|
||||
expect(store.state.ImageViewer.mediaList).toEqual([])
|
||||
expect(store.state.ImageViewer.loading).toEqual(false)
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/closeModal')
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.modalOpen).toEqual(false)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.currentIndex).toEqual(-1)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.mediaList).toEqual([])
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.loading).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('incrementIndex', () => {
|
||||
it('should be changed', () => {
|
||||
store.dispatch('ImageViewer/incrementIndex')
|
||||
expect(store.state.ImageViewer.currentIndex).toEqual(0)
|
||||
expect(store.state.ImageViewer.loading).toEqual(true)
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/incrementIndex')
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.currentIndex).toEqual(0)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.loading).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('decrementIndex', () => {
|
||||
it('should be changed', () => {
|
||||
store.dispatch('ImageViewer/decrementIndex')
|
||||
expect(store.state.ImageViewer.currentIndex).toEqual(-2)
|
||||
expect(store.state.ImageViewer.loading).toEqual(true)
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/decrementIndex')
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.currentIndex).toEqual(-2)
|
||||
expect(store.state.TimelineSpace.Modals.ImageViewer.loading).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -85,7 +96,7 @@ describe('ImageViewer', () => {
|
|||
describe('imageURL', () => {
|
||||
describe('currentIndex exists', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 0,
|
||||
mediaList: [
|
||||
{
|
||||
|
@ -98,7 +109,7 @@ describe('ImageViewer', () => {
|
|||
})
|
||||
})
|
||||
it('should return url', () => {
|
||||
const url = store.getters['ImageViewer/imageURL']
|
||||
const url = store.getters['TimelineSpace/Modals/ImageViewer/imageURL']
|
||||
expect(url).toEqual('http://joinmastodon.org')
|
||||
})
|
||||
})
|
||||
|
@ -107,7 +118,7 @@ describe('ImageViewer', () => {
|
|||
describe('imageType', () => {
|
||||
describe('currentIndex exists', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 0,
|
||||
mediaList: [
|
||||
{
|
||||
|
@ -120,7 +131,7 @@ describe('ImageViewer', () => {
|
|||
})
|
||||
})
|
||||
it('should return type', () => {
|
||||
const type = store.getters['ImageViewer/imageType']
|
||||
const type = store.getters['TimelineSpace/Modals/ImageViewer/imageType']
|
||||
expect(type).toEqual('image/png')
|
||||
})
|
||||
})
|
||||
|
@ -130,7 +141,7 @@ describe('ImageViewer', () => {
|
|||
describe('currentIndex > 0', () => {
|
||||
describe('mediaList > 1', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 1,
|
||||
mediaList: [
|
||||
{
|
||||
|
@ -143,13 +154,13 @@ describe('ImageViewer', () => {
|
|||
})
|
||||
})
|
||||
it('should return true', () => {
|
||||
const left = store.getters['ImageViewer/showLeft']
|
||||
const left = store.getters['TimelineSpace/Modals/ImageViewer/showLeft']
|
||||
expect(left).toEqual(true)
|
||||
})
|
||||
})
|
||||
describe('mediaList < 1', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 0,
|
||||
mediaList: [
|
||||
{
|
||||
|
@ -159,7 +170,7 @@ describe('ImageViewer', () => {
|
|||
})
|
||||
})
|
||||
it('should not return true', () => {
|
||||
const left = store.getters['ImageViewer/showLeft']
|
||||
const left = store.getters['TimelineSpace/Modals/ImageViewer/showLeft']
|
||||
expect(left).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
@ -170,7 +181,7 @@ describe('ImageViewer', () => {
|
|||
describe('current index is lower than media list length', () => {
|
||||
describe('media list length > 1', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 0,
|
||||
mediaList: [
|
||||
{
|
||||
|
@ -183,13 +194,13 @@ describe('ImageViewer', () => {
|
|||
})
|
||||
})
|
||||
it('should return true', () => {
|
||||
const right = store.getters['ImageViewer/showRight']
|
||||
const right = store.getters['TimelineSpace/Modals/ImageViewer/showRight']
|
||||
expect(right).toEqual(true)
|
||||
})
|
||||
})
|
||||
describe('media list length <= 1', () => {
|
||||
beforeEach(() => {
|
||||
store.dispatch('ImageViewer/openModal', {
|
||||
store.dispatch('TimelineSpace/Modals/ImageViewer/openModal', {
|
||||
currentIndex: 0,
|
||||
mediaList: [
|
||||
{
|
||||
|
@ -199,7 +210,7 @@ describe('ImageViewer', () => {
|
|||
})
|
||||
})
|
||||
it('should not return true', () => {
|
||||
const right = store.getters['ImageViewer/showRight']
|
||||
const right = store.getters['TimelineSpace/Modals/ImageViewer/showRight']
|
||||
expect(right).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import i18n from '~/src/config/i18n'
|
||||
import router from '@/router'
|
||||
import Jump, { JumpState, Channel } from '~/src/renderer/store/TimelineSpace/Modals/Jump'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const state = (): JumpState => {
|
||||
return {
|
||||
|
@ -59,34 +59,40 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const modalsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Jump: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
_id: '0'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Modals: modalsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
describe('Jump', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
Jump: initStore(),
|
||||
TimelineSpace: timelineState
|
||||
TimelineSpace: timelineStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('jumpCurrentSelected', () => {
|
||||
it('should be changed', () => {
|
||||
store.dispatch('Jump/jumpCurrentSelected')
|
||||
expect(store.state.Jump.modalOpen).toEqual(false)
|
||||
store.dispatch('TimelineSpace/Modals/Jump/jumpCurrentSelected')
|
||||
expect(store.state.TimelineSpace.Modals.Jump.modalOpen).toEqual(false)
|
||||
expect(router.push).toHaveBeenCalledWith({ path: '/0/home' })
|
||||
})
|
||||
})
|
||||
|
@ -97,8 +103,8 @@ describe('Jump', () => {
|
|||
name: 'public',
|
||||
path: 'public'
|
||||
}
|
||||
store.dispatch('Jump/jump', channel)
|
||||
expect(store.state.Jump.modalOpen).toEqual(false)
|
||||
store.dispatch('TimelineSpace/Modals/Jump/jump', channel)
|
||||
expect(store.state.TimelineSpace.Modals.Jump.modalOpen).toEqual(false)
|
||||
expect(router.push).toHaveBeenCalledWith({ path: '/0/public' })
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import ListMembership, { ListMembershipState } from '@/store/TimelineSpace/Modals/ListMembership'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getAccountLists: () => {
|
||||
|
@ -119,14 +119,24 @@ const initStore = () => {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineState = {
|
||||
const modalsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
ListMembership: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
_id: '0'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Modals: modalsStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
|
@ -136,16 +146,12 @@ const appState = {
|
|||
}
|
||||
|
||||
describe('ListMembership', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
ListMembership: initStore(),
|
||||
TimelineSpace: timelineState,
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
|
@ -153,17 +159,17 @@ describe('ListMembership', () => {
|
|||
|
||||
describe('fetchListMembership', () => {
|
||||
it('should get', async () => {
|
||||
await store.dispatch('ListMembership/fetchListMembership', {
|
||||
await store.dispatch('TimelineSpace/Modals/ListMembership/fetchListMembership', {
|
||||
id: '5'
|
||||
})
|
||||
expect(store.state.ListMembership.belongToLists).toEqual([list1, list2])
|
||||
expect(store.state.TimelineSpace.Modals.ListMembership.belongToLists).toEqual([list1, list2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchLists', () => {
|
||||
it('should be changed', async () => {
|
||||
await store.dispatch('ListMembership/fetchLists')
|
||||
expect(store.state.ListMembership.lists).toEqual([list1, list2])
|
||||
await store.dispatch('TimelineSpace/Modals/ListMembership/fetchLists')
|
||||
expect(store.state.TimelineSpace.Modals.ListMembership.lists).toEqual([list1, list2])
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -179,8 +185,8 @@ describe('ListMembership', () => {
|
|||
}
|
||||
})
|
||||
it('should be changed', async () => {
|
||||
await store.dispatch('ListMembership/changeBelongToLists', [list1.id, list2.id])
|
||||
expect(store.state.ListMembership.belongToLists).toEqual([list1, list2])
|
||||
await store.dispatch('TimelineSpace/Modals/ListMembership/changeBelongToLists', [list1.id, list2.id])
|
||||
expect(store.state.TimelineSpace.Modals.ListMembership.belongToLists).toEqual([list1, list2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Entity, Response } from 'megalodon'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import Vuex from 'vuex'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import SideMenu, { SideMenuState } from '~/src/renderer/store/TimelineSpace/SideMenu'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const mockClient = {
|
||||
getLists: () => {
|
||||
|
@ -82,25 +82,24 @@ const appStore = {
|
|||
}
|
||||
}
|
||||
|
||||
const timelineStore = {
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
SideMenu: initStore()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
describe('SideMenu', () => {
|
||||
let store
|
||||
let localVue
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
store = createStore({
|
||||
modules: {
|
||||
SideMenu: initStore(),
|
||||
App: appStore,
|
||||
TimelineSpace: timelineStore
|
||||
TimelineSpace: timelineStore()
|
||||
}
|
||||
})
|
||||
// mockedMegalodon.mockClear()
|
||||
|
@ -113,27 +112,27 @@ describe('SideMenu', () => {
|
|||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
const lists = await store.dispatch('SideMenu/fetchLists', account)
|
||||
expect(store.state.SideMenu.lists).toEqual([list1, list2])
|
||||
const lists = await store.dispatch('TimelineSpace/SideMenu/fetchLists', account)
|
||||
expect(store.state.TimelineSpace.SideMenu.lists).toEqual([list1, list2])
|
||||
expect(lists).toEqual([list1, list2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('clearUnread', () => {
|
||||
it('should be resetted', () => {
|
||||
store.dispatch('SideMenu/clearUnread')
|
||||
expect(store.state.SideMenu.unreadHomeTimeline).toEqual(false)
|
||||
expect(store.state.SideMenu.unreadNotifications).toEqual(false)
|
||||
expect(store.state.SideMenu.unreadLocalTimeline).toEqual(false)
|
||||
expect(store.state.SideMenu.unreadDirectMessagesTimeline).toEqual(false)
|
||||
expect(store.state.SideMenu.unreadPublicTimeline).toEqual(false)
|
||||
store.dispatch('TimelineSpace/SideMenu/clearUnread')
|
||||
expect(store.state.TimelineSpace.SideMenu.unreadHomeTimeline).toEqual(false)
|
||||
expect(store.state.TimelineSpace.SideMenu.unreadNotifications).toEqual(false)
|
||||
expect(store.state.TimelineSpace.SideMenu.unreadLocalTimeline).toEqual(false)
|
||||
expect(store.state.TimelineSpace.SideMenu.unreadDirectMessagesTimeline).toEqual(false)
|
||||
expect(store.state.TimelineSpace.SideMenu.unreadPublicTimeline).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('changeCollapse', () => {
|
||||
it('should be changed', () => {
|
||||
store.dispatch('SideMenu/changeCollapse', true)
|
||||
expect(store.state.SideMenu.collapse).toEqual(true)
|
||||
store.dispatch('TimelineSpace/SideMenu/changeCollapse', true)
|
||||
expect(store.state.TimelineSpace.SideMenu.collapse).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -142,8 +141,8 @@ describe('SideMenu', () => {
|
|||
ipcMain.handle('get-collapse', () => {
|
||||
return true
|
||||
})
|
||||
await store.dispatch('SideMenu/readCollapse')
|
||||
expect(store.state.SideMenu.collapse).toEqual(true)
|
||||
await store.dispatch('TimelineSpace/SideMenu/readCollapse')
|
||||
expect(store.state.TimelineSpace.SideMenu.collapse).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -158,8 +157,8 @@ describe('SideMenu', () => {
|
|||
ipcMain.handle('list-hashtags', () => {
|
||||
return [tag1, tag2]
|
||||
})
|
||||
await store.dispatch('SideMenu/listTags')
|
||||
expect(store.state.SideMenu.tags).toEqual([tag1, tag2])
|
||||
await store.dispatch('TimelineSpace/SideMenu/listTags')
|
||||
expect(store.state.TimelineSpace.SideMenu.tags).toEqual([tag1, tag2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ import Bookmarks, { BookmarksState } from './Contents/Bookmarks'
|
|||
import Local, { LocalState } from './Contents/Local'
|
||||
import Public, { PublicState } from './Contents/Public'
|
||||
import Search, { SearchModuleState } from './Contents/Search'
|
||||
import Lists from './Contents/Lists'
|
||||
import Lists, { ListsModuleState } from './Contents/Lists'
|
||||
import Hashtag, { HashtagModuleState } from './Contents/Hashtag'
|
||||
import DirectMessages, { DirectMessagesState } from './Contents/DirectMessages'
|
||||
import FollowRequests, { FollowRequestsState } from './Contents/FollowRequests'
|
||||
|
@ -31,6 +31,7 @@ type ContentsModule = {
|
|||
Search: SearchModuleState
|
||||
Hashtag: HashtagModuleState
|
||||
FollowRequests: FollowRequestsState
|
||||
Lists: ListsModuleState
|
||||
}
|
||||
|
||||
export type ContentsModuleState = ContentsModule & ContentsState
|
||||
|
|
|
@ -222,6 +222,9 @@ const actions: ActionTree<MentionsState, RootState> = {
|
|||
return res.data
|
||||
},
|
||||
getMarker: async ({ rootState }): Promise<LocalMarker | null> => {
|
||||
if (!rootState.TimelineSpace.timelineSetting.useMarker.mentions) {
|
||||
return null
|
||||
}
|
||||
const localMarker: LocalMarker | null = await win.ipcRenderer.invoke('get-mentions-marker', rootState.TimelineSpace.account._id)
|
||||
return localMarker
|
||||
},
|
||||
|
|
|
@ -2131,11 +2131,6 @@
|
|||
resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.2.33.tgz#69a8c99ceb37c1b031d5cc4aec2ff1dc77e1161e"
|
||||
integrity sha512-UBc1Pg1T3yZ97vsA2ueER0F6GbJebLHYlEi4ou1H5YL4KWvMOOWwpYo9/QpWq93wxKG6Wo13IY74Hcn/f7c7Bg==
|
||||
|
||||
"@vue/test-utils@^2.0.0-rc.20":
|
||||
version "2.0.0-rc.20"
|
||||
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-2.0.0-rc.20.tgz#1fff871d6ad1b6154e02e3e9f2462ec258cb5459"
|
||||
integrity sha512-aSkOAzM/ZlIyYgN7yj661FTjhFZZy5i9+FUbbDNoMGYA4F1WKwDdcDCPj9B/qzt3wGFkuCP5PO6SBtdSTMEhIA==
|
||||
|
||||
"@vueuse/core@^8.2.4":
|
||||
version "8.2.6"
|
||||
resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-8.2.6.tgz#baf674acadd678b0429c60477213c6dab08ea9e0"
|
||||
|
|
Loading…
Reference in New Issue