refs #850 Fix test for typescript in Preferences
This commit is contained in:
parent
ca6fc13975
commit
9456374516
|
@ -29,6 +29,8 @@ module.exports = {
|
||||||
{
|
{
|
||||||
'argsIgnorePattern': '^_'
|
'argsIgnorePattern': '^_'
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
'camelcase': 'off',
|
||||||
|
'@typescript-eslint/camelcase': 'off'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
import { createLocalVue } from '@vue/test-utils'
|
import { createLocalVue } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import { ipcMain } from '~/spec/mock/electron'
|
import { ipcMain } from '~/spec/mock/electron'
|
||||||
import Account from '@/store/Preferences/Account'
|
import Account, { AccountState } from '@/store/Preferences/Account'
|
||||||
|
import AccountType from '~/src/types/account'
|
||||||
|
|
||||||
const state = () => {
|
const account: AccountType = {
|
||||||
|
_id: 'sample',
|
||||||
|
baseURL: 'http://example.com',
|
||||||
|
domain: 'example.com',
|
||||||
|
clientId: 'hoge',
|
||||||
|
clientSecret: 'hogehoge',
|
||||||
|
accessToken: null,
|
||||||
|
refreshToken: null,
|
||||||
|
username: null,
|
||||||
|
accountId: null,
|
||||||
|
avatar: null,
|
||||||
|
order: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = (): AccountState => {
|
||||||
return {
|
return {
|
||||||
accounts: [],
|
accounts: [],
|
||||||
accountLoading: false
|
accountLoading: false
|
||||||
|
@ -35,7 +50,7 @@ describe('Account', () => {
|
||||||
|
|
||||||
describe('loadAccounts', () => {
|
describe('loadAccounts', () => {
|
||||||
it('error', async () => {
|
it('error', async () => {
|
||||||
ipcMain.once('list-accounts', (event, _) => {
|
ipcMain.once('list-accounts', (event: any, _) => {
|
||||||
event.sender.send('error-list-accounts', new Error())
|
event.sender.send('error-list-accounts', new Error())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -45,86 +60,86 @@ describe('Account', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('success', async () => {
|
it('success', async () => {
|
||||||
ipcMain.once('list-accounts', (event, _) => {
|
ipcMain.once('list-accounts', (event: any, _) => {
|
||||||
event.sender.send('response-list-accounts', ['accounts'])
|
event.sender.send('response-list-accounts', [account])
|
||||||
})
|
})
|
||||||
await store.dispatch('Account/loadAccounts')
|
await store.dispatch('Account/loadAccounts')
|
||||||
expect(store.state.Account.accounts).toEqual(['accounts'])
|
expect(store.state.Account.accounts).toEqual([account])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('removeAccount', () => {
|
describe('removeAccount', () => {
|
||||||
it('error', async () => {
|
it('error', async () => {
|
||||||
ipcMain.once('remove-account', (event, _) => {
|
ipcMain.once('remove-account', (event: any, _) => {
|
||||||
event.sender.send('error-remove-account', new Error())
|
event.sender.send('error-remove-account', new Error())
|
||||||
})
|
})
|
||||||
await store.dispatch('Account/removeAccount', 'account')
|
await store.dispatch('Account/removeAccount', account)
|
||||||
.catch((err: Error) => {
|
.catch((err: Error) => {
|
||||||
expect(err instanceof Error).toEqual(true)
|
expect(err instanceof Error).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('success', async () => {
|
it('success', async () => {
|
||||||
ipcMain.once('remove-account', (event, _) => {
|
ipcMain.once('remove-account', (event: any, _) => {
|
||||||
event.sender.send('response-remove-account', 1)
|
event.sender.send('response-remove-account')
|
||||||
})
|
})
|
||||||
const res = await store.dispatch('Account/removeAccount', 'account')
|
const res = await store.dispatch('Account/removeAccount', account)
|
||||||
expect(res).toEqual(undefined)
|
expect(res).toEqual(undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('forwardAccount', () => {
|
describe('forwardAccount', () => {
|
||||||
it('error', async () => {
|
it('error', async () => {
|
||||||
ipcMain.once('forward-account', (event, _) => {
|
ipcMain.once('forward-account', (event: any, _) => {
|
||||||
event.sender.send('error-forward-account', new Error())
|
event.sender.send('error-forward-account', new Error())
|
||||||
})
|
})
|
||||||
await store.dispatch('Account/forwardAccount', 'account')
|
await store.dispatch('Account/forwardAccount', account)
|
||||||
.catch((err: Error) => {
|
.catch((err: Error) => {
|
||||||
expect(err instanceof Error).toEqual(true)
|
expect(err instanceof Error).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('success', async () => {
|
it('success', async () => {
|
||||||
ipcMain.once('forward-account', (event, _) => {
|
ipcMain.once('forward-account', (event: any, _) => {
|
||||||
event.sender.send('response-forward-account', 1)
|
event.sender.send('response-forward-account')
|
||||||
})
|
})
|
||||||
const res = await store.dispatch('Account/forwardAccount', 'account')
|
const res = await store.dispatch('Account/forwardAccount', account)
|
||||||
expect(res).toEqual(undefined)
|
expect(res).toEqual(undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('backwardAccount', () => {
|
describe('backwardAccount', () => {
|
||||||
it('error', async () => {
|
it('error', async () => {
|
||||||
ipcMain.once('backward-account', (event, _) => {
|
ipcMain.once('backward-account', (event: any, _) => {
|
||||||
event.sender.send('error-backward-account', new Error())
|
event.sender.send('error-backward-account', new Error())
|
||||||
})
|
})
|
||||||
await store.dispatch('Account/backwardAccount', 'account')
|
await store.dispatch('Account/backwardAccount', account)
|
||||||
.catch((err: Error) => {
|
.catch((err: Error) => {
|
||||||
expect(err instanceof Error).toEqual(true)
|
expect(err instanceof Error).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('success', async () => {
|
it('success', async () => {
|
||||||
ipcMain.once('backward-account', (event, _) => {
|
ipcMain.once('backward-account', (event: any, _) => {
|
||||||
event.sender.send('response-backward-account', 1)
|
event.sender.send('response-backward-account')
|
||||||
})
|
})
|
||||||
const res = await store.dispatch('Account/backwardAccount', 'account')
|
const res = await store.dispatch('Account/backwardAccount', account)
|
||||||
expect(res).toEqual(undefined)
|
expect(res).toEqual(undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('removeAllAccounts', () => {
|
describe('removeAllAccounts', () => {
|
||||||
it('error', async () => {
|
it('error', async () => {
|
||||||
ipcMain.once('remove-all-accounts', (event, _) => {
|
ipcMain.once('remove-all-accounts', (event: any, _) => {
|
||||||
event.sender.send('error-remove-all-accounts', new Error())
|
event.sender.send('error-remove-all-accounts', new Error())
|
||||||
})
|
})
|
||||||
await store.dispatch('Account/removeAllAccounts', 'account')
|
await store.dispatch('Account/removeAllAccounts', account)
|
||||||
.catch((err: Error) => {
|
.catch((err: Error) => {
|
||||||
expect(err instanceof Error).toEqual(true)
|
expect(err instanceof Error).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
it('success', async () => {
|
it('success', async () => {
|
||||||
ipcMain.once('remove-all-accounts', (event, _) => {
|
ipcMain.once('remove-all-accounts', (event: any, _) => {
|
||||||
event.sender.send('response-remove-all-accounts', 1)
|
event.sender.send('response-remove-all-accounts')
|
||||||
})
|
})
|
||||||
const res = await store.dispatch('Account/removeAllAccounts', 'account')
|
const res = await store.dispatch('Account/removeAllAccounts', account)
|
||||||
expect(res).toEqual(undefined)
|
expect(res).toEqual(undefined)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,10 +5,10 @@ import DisplayStyle from '~/src/constants/displayStyle'
|
||||||
import TimeFormat from '~/src/constants/timeFormat'
|
import TimeFormat from '~/src/constants/timeFormat'
|
||||||
import { LightTheme, DarkTheme } from '~/src/renderer/utils/theme'
|
import { LightTheme, DarkTheme } from '~/src/renderer/utils/theme'
|
||||||
import DefaultFonts from '@/utils/fonts'
|
import DefaultFonts from '@/utils/fonts'
|
||||||
import Appearance from '@/store/Preferences/Appearance'
|
import Appearance, { AppearanceState } from '@/store/Preferences/Appearance'
|
||||||
import { ipcMain } from '~/spec/mock/electron'
|
import { ipcMain } from '~/spec/mock/electron'
|
||||||
|
|
||||||
const state = () => {
|
const state = (): AppearanceState => {
|
||||||
return {
|
return {
|
||||||
appearance: {
|
appearance: {
|
||||||
theme: Theme.Light.key,
|
theme: Theme.Light.key,
|
||||||
|
@ -51,14 +51,14 @@ describe('Preferences/Appearance', () => {
|
||||||
App: App
|
App: App
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ipcMain.once('update-preferences', (event, config) => {
|
ipcMain.once('update-preferences', (event: any, config: any) => {
|
||||||
event.sender.send('response-update-preferences', config)
|
event.sender.send('response-update-preferences', config)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('load', () => {
|
describe('load', () => {
|
||||||
it('loadAppearance', async () => {
|
it('loadAppearance', async () => {
|
||||||
ipcMain.once('get-preferences', (event, _) => {
|
ipcMain.once('get-preferences', (event: any, _) => {
|
||||||
event.sender.send('response-get-preferences', {
|
event.sender.send('response-get-preferences', {
|
||||||
appearance: {
|
appearance: {
|
||||||
theme: Theme.Dark.key,
|
theme: Theme.Dark.key,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { createLocalVue } from '@vue/test-utils'
|
import { createLocalVue } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import { ipcMain } from '~/spec/mock/electron'
|
import { ipcMain } from '~/spec/mock/electron'
|
||||||
import General from '@/store/Preferences/General'
|
import General, { GeneralState } from '@/store/Preferences/General'
|
||||||
|
|
||||||
const state = () => {
|
const state = (): GeneralState => {
|
||||||
return {
|
return {
|
||||||
general: {
|
general: {
|
||||||
sound: {
|
sound: {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { createLocalVue } from '@vue/test-utils'
|
import { createLocalVue } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import { ipcMain } from '~/spec/mock/electron'
|
import { ipcMain } from '~/spec/mock/electron'
|
||||||
import Language from '@/store/Preferences/Language'
|
import Language, { LanguageState } from '@/store/Preferences/Language'
|
||||||
import DefaultLanguage from '~/src/constants/language'
|
import DefaultLanguage from '~/src/constants/language'
|
||||||
|
|
||||||
const state = () => {
|
const state = (): LanguageState => {
|
||||||
return {
|
return {
|
||||||
language: {
|
language: {
|
||||||
language: DefaultLanguage.en.key
|
language: DefaultLanguage.en.key
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { createLocalVue } from '@vue/test-utils'
|
import { createLocalVue } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import { ipcMain } from '~/spec/mock/electron'
|
import { ipcMain } from '~/spec/mock/electron'
|
||||||
import Notification from '@/store/Preferences/Notification'
|
import Notification, { NotificationState } from '@/store/Preferences/Notification'
|
||||||
|
|
||||||
const state = () => {
|
const state = (): NotificationState => {
|
||||||
return {
|
return {
|
||||||
notification: {
|
notification: {
|
||||||
notify: {
|
notify: {
|
||||||
|
|
|
@ -1,8 +1,23 @@
|
||||||
import Account from '@/store/Preferences/Account'
|
import Account, { AccountState, MUTATION_TYPES } from '@/store/Preferences/Account'
|
||||||
|
import AccountType from '~/src/types/account'
|
||||||
|
|
||||||
|
const account: AccountType = {
|
||||||
|
_id: 'sample',
|
||||||
|
baseURL: 'http://example.com',
|
||||||
|
domain: 'example.com',
|
||||||
|
clientId: 'hoge',
|
||||||
|
clientSecret: 'hogehoge',
|
||||||
|
accessToken: null,
|
||||||
|
refreshToken: null,
|
||||||
|
username: null,
|
||||||
|
accountId: null,
|
||||||
|
avatar: null,
|
||||||
|
order: 1
|
||||||
|
}
|
||||||
|
|
||||||
describe('Preferences/Account', () => {
|
describe('Preferences/Account', () => {
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
let state
|
let state: AccountState
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
state = {
|
state = {
|
||||||
accounts: [],
|
accounts: [],
|
||||||
|
@ -11,13 +26,13 @@ describe('Preferences/Account', () => {
|
||||||
})
|
})
|
||||||
describe('updateAccounts', () => {
|
describe('updateAccounts', () => {
|
||||||
it('should be updated', () => {
|
it('should be updated', () => {
|
||||||
Account.mutations.updateAccounts(state, ['account'])
|
Account.mutations![MUTATION_TYPES.UPDATE_ACCOUNTS](state, [account])
|
||||||
expect(state.accounts).toEqual(['account'])
|
expect(state.accounts).toEqual([account])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('updateAccountLoading', () => {
|
describe('updateAccountLoading', () => {
|
||||||
it('should be update', () => {
|
it('should be update', () => {
|
||||||
Account.mutations.updateAccountLoading(state, true)
|
Account.mutations![MUTATION_TYPES.UPDATE_ACCOUNT_LOADING](state, true)
|
||||||
expect(state.accountLoading).toEqual(true)
|
expect(state.accountLoading).toEqual(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,10 +3,10 @@ import DisplayStyle from '~/src/constants/displayStyle'
|
||||||
import TimeFormat from '~/src/constants/timeFormat'
|
import TimeFormat from '~/src/constants/timeFormat'
|
||||||
import { LightTheme } from '~/src/renderer/utils/theme'
|
import { LightTheme } from '~/src/renderer/utils/theme'
|
||||||
import DefaultFonts from '@/utils/fonts'
|
import DefaultFonts from '@/utils/fonts'
|
||||||
import Appearance from '@/store/Preferences/Appearance'
|
import Appearance, { AppearanceState, MUTATION_TYPES } from '@/store/Preferences/Appearance'
|
||||||
|
|
||||||
describe('Preferences/Appearance', () => {
|
describe('Preferences/Appearance', () => {
|
||||||
let state
|
let state: AppearanceState
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
state = {
|
state = {
|
||||||
appearance: {
|
appearance: {
|
||||||
|
@ -23,7 +23,7 @@ describe('Preferences/Appearance', () => {
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
describe('updateAppearance', () => {
|
describe('updateAppearance', () => {
|
||||||
it('should be changed', () => {
|
it('should be changed', () => {
|
||||||
Appearance.mutations.updateAppearance(state, {
|
Appearance.mutations![MUTATION_TYPES.UPDATE_APPEARANCE](state, {
|
||||||
theme: Theme.Dark.key
|
theme: Theme.Dark.key
|
||||||
})
|
})
|
||||||
expect(state.appearance.theme).toEqual(Theme.Dark.key)
|
expect(state.appearance.theme).toEqual(Theme.Dark.key)
|
||||||
|
@ -31,7 +31,7 @@ describe('Preferences/Appearance', () => {
|
||||||
})
|
})
|
||||||
describe('updateFonts', () => {
|
describe('updateFonts', () => {
|
||||||
it('should be changed', () => {
|
it('should be changed', () => {
|
||||||
Appearance.mutations.updateFonts(state, ['font'])
|
Appearance.mutations![MUTATION_TYPES.UPDATE_FONTS](state, ['font'])
|
||||||
expect(state.fonts).toEqual(['font'])
|
expect(state.fonts).toEqual(['font'])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
import General from '@/store/Preferences/General'
|
import General, { GeneralState, MUTATION_TYPES } from '@/store/Preferences/General'
|
||||||
|
|
||||||
describe('Preferences/General', () => {
|
describe('Preferences/General', () => {
|
||||||
let state
|
let state: GeneralState
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
state = {
|
state = {
|
||||||
general: {
|
general: {
|
||||||
sound: {
|
sound: {
|
||||||
fav_rb: true,
|
fav_rb: true,
|
||||||
toot: true
|
toot: true
|
||||||
|
},
|
||||||
|
timeline: {
|
||||||
|
cw: false,
|
||||||
|
nfsw: false,
|
||||||
|
hideAllAttachments: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loading: false
|
loading: false
|
||||||
|
@ -16,7 +21,7 @@ describe('Preferences/General', () => {
|
||||||
|
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
it('updateGeneral', () => {
|
it('updateGeneral', () => {
|
||||||
General.mutations.updateGeneral(state, {
|
General.mutations![MUTATION_TYPES.UPDATE_GENERAL](state, {
|
||||||
sound: {
|
sound: {
|
||||||
fav_rb: false,
|
fav_rb: false,
|
||||||
toot: false
|
toot: false
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Language from '@/store/Preferences/Language'
|
import Language, { LanguageState, MUTATION_TYPES } from '@/store/Preferences/Language'
|
||||||
import DefaultLanguage from '~/src/constants/language'
|
import DefaultLanguage from '~/src/constants/language'
|
||||||
|
|
||||||
describe('Preferences/Language', () => {
|
describe('Preferences/Language', () => {
|
||||||
let state
|
let state: LanguageState
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
state = {
|
state = {
|
||||||
language: {
|
language: {
|
||||||
|
@ -13,7 +13,7 @@ describe('Preferences/Language', () => {
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
describe('updateLanguage', () => {
|
describe('updateLanguage', () => {
|
||||||
it('should be updated', () => {
|
it('should be updated', () => {
|
||||||
Language.mutations.updateLanguage(state, {
|
Language.mutations![MUTATION_TYPES.UPDATE_LANGUAGE](state, {
|
||||||
language: DefaultLanguage.ja.key
|
language: DefaultLanguage.ja.key
|
||||||
})
|
})
|
||||||
expect(state.language.language).toEqual(DefaultLanguage.ja.key)
|
expect(state.language.language).toEqual(DefaultLanguage.ja.key)
|
||||||
|
@ -21,7 +21,7 @@ describe('Preferences/Language', () => {
|
||||||
})
|
})
|
||||||
describe('changeLanguage', () => {
|
describe('changeLanguage', () => {
|
||||||
it('should be changed', () => {
|
it('should be changed', () => {
|
||||||
Language.mutations.changeLanguage(state, DefaultLanguage.ja.key)
|
Language.mutations![MUTATION_TYPES.CHANGE_LANGUAGE](state, DefaultLanguage.ja.key)
|
||||||
expect(state.language.language).toEqual(DefaultLanguage.ja.key)
|
expect(state.language.language).toEqual(DefaultLanguage.ja.key)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import Notification from '@/store/Preferences/Notification'
|
import Notification, { NotificationState, MUTATION_TYPES } from '@/store/Preferences/Notification'
|
||||||
|
|
||||||
describe('Preferences/Notification', () => {
|
describe('Preferences/Notification', () => {
|
||||||
let state
|
let state: NotificationState
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
state = {
|
state = {
|
||||||
notification: {
|
notification: {
|
||||||
|
@ -16,7 +16,7 @@ describe('Preferences/Notification', () => {
|
||||||
})
|
})
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
it('updateNotification', () => {
|
it('updateNotification', () => {
|
||||||
Notification.mutations.updateNotification(state, {
|
Notification.mutations![MUTATION_TYPES.UPDATE_NOTIFICATION](state, {
|
||||||
notify: {
|
notify: {
|
||||||
reply: false,
|
reply: false,
|
||||||
reblog: false,
|
reblog: false,
|
||||||
|
|
Loading…
Reference in New Issue