fixup! [refactor] Remove authorize store
This commit is contained in:
parent
df5ecdf9fd
commit
3eb65b0ee7
|
@ -1,66 +0,0 @@
|
||||||
import { createStore, Store } from 'vuex'
|
|
||||||
import { ipcRenderer } from '~/spec/mock/electron'
|
|
||||||
import Login, { LoginState } from '@/store/Login'
|
|
||||||
import { MyWindow } from '~/src/types/global'
|
|
||||||
import { RootState } from '@/store'
|
|
||||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
|
||||||
|
|
||||||
jest.mock('megalodon', () => ({
|
|
||||||
...jest.requireActual<object>('megalodon'),
|
|
||||||
detector: jest.fn(() => 'pleroma'),
|
|
||||||
__esModule: true
|
|
||||||
}))
|
|
||||||
|
|
||||||
const state = (): LoginState => {
|
|
||||||
return {
|
|
||||||
domain: null,
|
|
||||||
searching: false,
|
|
||||||
server: null,
|
|
||||||
appData: null,
|
|
||||||
sns: 'mastodon'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const initStore = () => {
|
|
||||||
return {
|
|
||||||
namespaced: true,
|
|
||||||
state: state(),
|
|
||||||
actions: Login.actions,
|
|
||||||
mutations: Login.mutations
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const appState = {
|
|
||||||
namespaced: true,
|
|
||||||
state: {
|
|
||||||
proxyConfiguration: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Login', () => {
|
|
||||||
let store: Store<RootState>
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
store = createStore({
|
|
||||||
modules: {
|
|
||||||
Login: initStore(),
|
|
||||||
App: appState
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('pageBack', () => {
|
|
||||||
it('should reset instance', () => {
|
|
||||||
store.dispatch('Login/pageBack')
|
|
||||||
expect(store.state.Login.domain).toEqual(null)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('confirmInstance', () => {
|
|
||||||
it('should change instance', async () => {
|
|
||||||
const result = await store.dispatch('Login/confirmInstance', 'pleroma.io')
|
|
||||||
expect(result).toEqual(true)
|
|
||||||
expect(store.state.Login.domain).toEqual('pleroma.io')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -1,28 +0,0 @@
|
||||||
import Login, { LoginState, MUTATION_TYPES } from '@/store/Login'
|
|
||||||
|
|
||||||
describe('Login', () => {
|
|
||||||
describe('mutations', () => {
|
|
||||||
let state: LoginState
|
|
||||||
beforeEach(() => {
|
|
||||||
state = {
|
|
||||||
domain: null,
|
|
||||||
searching: false,
|
|
||||||
server: null,
|
|
||||||
appData: null,
|
|
||||||
sns: 'mastodon'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
describe('changeInstance', () => {
|
|
||||||
it('should be changed', () => {
|
|
||||||
Login.mutations![MUTATION_TYPES.CHANGE_DOMAIN](state, 'pleroma.io')
|
|
||||||
expect(state.domain).toEqual('pleroma.io')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('changeSearching', () => {
|
|
||||||
it('should be changed', () => {
|
|
||||||
Login.mutations![MUTATION_TYPES.CHANGE_SEARCHING](state, true)
|
|
||||||
expect(state.searching).toEqual(true)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
Loading…
Reference in New Issue