refs #2500 Fix tests
This commit is contained in:
parent
20a22cc30e
commit
a68a24e4f9
|
@ -3,7 +3,7 @@ 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 {
|
||||
|
@ -58,21 +58,6 @@ describe('GlobalHeader', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('refreshAccounts', () => {
|
||||
beforeEach(() => {
|
||||
ipcMain.handle('refresh-accounts', () => {
|
||||
return ['accounts']
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
ipcMain.removeHandler('refresh-accounts')
|
||||
})
|
||||
it('should be refreshed', async () => {
|
||||
await store.dispatch('GlobalHeader/refreshAccounts')
|
||||
expect(store.state.GlobalHeader.accounts).toEqual(['accounts'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeShortcutEvents', () => {
|
||||
it('should be removed', async () => {
|
||||
const removed = await store.dispatch('GlobalHeader/removeShortcutEvents')
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
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
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
|
@ -13,8 +13,10 @@ jest.mock('megalodon', () => ({
|
|||
|
||||
const state = (): LoginState => {
|
||||
return {
|
||||
selectedInstance: null,
|
||||
domain: null,
|
||||
searching: false,
|
||||
server: null,
|
||||
appData: null,
|
||||
sns: 'mastodon'
|
||||
}
|
||||
}
|
||||
|
@ -47,34 +49,10 @@ describe('Login', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('fetchLogin', () => {
|
||||
describe('error', () => {
|
||||
it('should return error', async () => {
|
||||
ipcMain.handle('get-auth-url', () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Login/fetchLogin', 'pleroma.io').catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('get-auth-url')
|
||||
})
|
||||
})
|
||||
describe('success', () => {
|
||||
it('should return url', async () => {
|
||||
ipcMain.handle('get-auth-url', () => {
|
||||
return 'http://example.com/auth'
|
||||
})
|
||||
const url = await store.dispatch('Login/fetchLogin', 'pleroma.io')
|
||||
expect(url).toEqual('http://example.com/auth')
|
||||
ipcMain.removeHandler('get-auth-url')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('pageBack', () => {
|
||||
it('should reset instance', () => {
|
||||
store.dispatch('Login/pageBack')
|
||||
expect(store.state.Login.selectedInstance).toEqual(null)
|
||||
expect(store.state.Login.domain).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -82,7 +60,7 @@ describe('Login', () => {
|
|||
it('should change instance', async () => {
|
||||
const result = await store.dispatch('Login/confirmInstance', 'pleroma.io')
|
||||
expect(result).toEqual(true)
|
||||
expect(store.state.Login.selectedInstance).toEqual('pleroma.io')
|
||||
expect(store.state.Login.domain).toEqual('pleroma.io')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
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'
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const account: LocalAccount = {
|
||||
_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 {
|
||||
accounts: [],
|
||||
accountLoading: false
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Account.actions,
|
||||
mutations: Account.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const preferencesStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Account: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
describe('Account', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
Preferences: preferencesStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('loadAccounts', () => {
|
||||
it('error', async () => {
|
||||
ipcMain.handle('list-accounts', async () => {
|
||||
throw new Error()
|
||||
})
|
||||
|
||||
await store.dispatch('Preferences/Account/loadAccounts').catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('list-accounts')
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.handle('list-accounts', () => {
|
||||
return [account]
|
||||
})
|
||||
await store.dispatch('Preferences/Account/loadAccounts')
|
||||
expect(store.state.Preferences.Account.accounts).toEqual([account])
|
||||
ipcMain.removeHandler('list-accounts')
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeAccount', () => {
|
||||
it('error', async () => {
|
||||
ipcMain.handle('remove-account', async () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Preferences/Account/removeAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('remove-account')
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.handle('remove-account', () => {
|
||||
return true
|
||||
})
|
||||
const res = await store.dispatch('Preferences/Account/removeAccount', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('remove-account')
|
||||
})
|
||||
})
|
||||
|
||||
describe('forwardAccount', () => {
|
||||
it('error', async () => {
|
||||
ipcMain.handle('forward-account', async () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Preferences/Account/forwardAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('forward-account')
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.handle('forward-account', () => {
|
||||
return {}
|
||||
})
|
||||
const res = await store.dispatch('Preferences/Account/forwardAccount', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('forward-account')
|
||||
})
|
||||
})
|
||||
|
||||
describe('backwardAccount', () => {
|
||||
it('error', async () => {
|
||||
ipcMain.handle('backward-account', () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Preferences/Account/backwardAccount', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('backward-account')
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.handle('backward-account', () => {
|
||||
return {}
|
||||
})
|
||||
const res = await store.dispatch('Preferences/Account/backwardAccount', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('backward-account')
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeAllAccounts', () => {
|
||||
it('error', async () => {
|
||||
ipcMain.handle('remove-all-accounts', () => {
|
||||
throw new Error()
|
||||
})
|
||||
await store.dispatch('Preferences/Account/removeAllAccounts', account).catch((err: Error) => {
|
||||
expect(err instanceof Error).toEqual(true)
|
||||
})
|
||||
ipcMain.removeHandler('remove-all-accounts')
|
||||
})
|
||||
it('success', async () => {
|
||||
ipcMain.handle('remove-all-accounts', () => {
|
||||
return {}
|
||||
})
|
||||
const res = await store.dispatch('Preferences/Account/removeAllAccounts', account)
|
||||
expect(res).toEqual(undefined)
|
||||
ipcMain.removeHandler('remove-all-accounts')
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,286 +0,0 @@
|
|||
import { RootState } from '@/store'
|
||||
import { Entity, Response } from 'megalodon'
|
||||
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
|
||||
|
||||
const emacsEmoji: Entity.Emoji = {
|
||||
shortcode: 'emacs',
|
||||
url: 'http://example.com/emacs',
|
||||
static_url: 'http://example.com/emacs',
|
||||
visible_in_picker: true
|
||||
}
|
||||
const rubyEmoji: Entity.Emoji = {
|
||||
shortcode: 'ruby',
|
||||
url: 'http://example.com/ruby',
|
||||
static_url: 'http://example.com/ruby',
|
||||
visible_in_picker: true
|
||||
}
|
||||
|
||||
const mockedInstance: Entity.Instance = {
|
||||
uri: 'http://pleroma.io',
|
||||
title: 'pleroma',
|
||||
description: '',
|
||||
email: 'test@example.com',
|
||||
version: '2.5.0 (compatible; Pleroma 0.9.0-3363-g7c5d2dc7)',
|
||||
thumbnail: null,
|
||||
urls: {
|
||||
streaming_api: 'wss://pleroma.io'
|
||||
},
|
||||
stats: {
|
||||
user_count: 10,
|
||||
status_count: 1000,
|
||||
domain_count: 100
|
||||
},
|
||||
languages: ['en'],
|
||||
contact_account: null,
|
||||
max_toot_chars: 5000
|
||||
}
|
||||
|
||||
const mockClient = {
|
||||
getInstance: () => {
|
||||
return new Promise<Response<Entity.Instance>>(resolve => {
|
||||
const res: Response<Entity.Instance> = {
|
||||
data: mockedInstance,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
},
|
||||
getInstanceCustomEmojis: () => {
|
||||
return new Promise<Response<Array<Entity.Emoji>>>(resolve => {
|
||||
const res: Response<Array<Entity.Emoji>> = {
|
||||
data: [emacsEmoji, rubyEmoji],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
detector: jest.fn(() => 'pleroma'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const state = (): TimelineSpaceState => {
|
||||
return {
|
||||
account: blankAccount,
|
||||
bindingAccount: null,
|
||||
loading: false,
|
||||
emojis: [],
|
||||
tootMax: 500,
|
||||
timelineSetting: {
|
||||
unreadNotification: {
|
||||
direct: true,
|
||||
local: true,
|
||||
public: true
|
||||
},
|
||||
useMarker: {
|
||||
home: false,
|
||||
notifications: true
|
||||
}
|
||||
},
|
||||
sns: 'mastodon',
|
||||
filters: []
|
||||
}
|
||||
}
|
||||
|
||||
const homeStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
fetchTimeline: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const notificationStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
fetchNotifications: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const DMStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
fetchTimeline: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const LocalStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
fetchLocalTimeline: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const PublicStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
fetchPublicTimeline: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const MentionStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
fetchMentions: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const contentsStore = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Home: homeStore,
|
||||
Notifications: notificationStore,
|
||||
DirectMessages: DMStore,
|
||||
Local: LocalStore,
|
||||
Public: PublicStore,
|
||||
Mentions: MentionStore
|
||||
},
|
||||
actions: {
|
||||
changeLoading: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore
|
||||
},
|
||||
state: state(),
|
||||
actions: TimelineSpace.actions,
|
||||
mutations: TimelineSpace.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('TimelineSpace', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: initStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('localAccount', () => {
|
||||
describe('account already exists', () => {
|
||||
beforeEach(() => {
|
||||
ipcMain.handle('get-local-account', () => {
|
||||
return {
|
||||
username: 'test'
|
||||
}
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
ipcMain.removeHandler('get-local-account')
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/localAccount', 1)
|
||||
expect(store.state.TimelineSpace.account.username).toEqual('test')
|
||||
})
|
||||
})
|
||||
|
||||
describe('account does not exist', () => {
|
||||
beforeEach(() => {
|
||||
ipcMain.handle('get-local-account', () => {
|
||||
return {}
|
||||
})
|
||||
ipcMain.handle('update-account', () => {
|
||||
return {
|
||||
username: 'fetched'
|
||||
}
|
||||
})
|
||||
})
|
||||
afterEach(() => {
|
||||
ipcMain.removeHandler('get-local-account')
|
||||
ipcMain.removeHandler('update-account')
|
||||
})
|
||||
it('should be fetched', async () => {
|
||||
await store.dispatch('TimelineSpace/localAccount', 1)
|
||||
expect(store.state.TimelineSpace.account.username).toEqual('fetched')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('detectSNS', () => {
|
||||
describe('API is pleroma', () => {
|
||||
it('should be detected', async () => {
|
||||
await store.dispatch('TimelineSpace/detectSNS')
|
||||
expect(store.state.TimelineSpace.sns).toEqual('pleroma')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchEmojis', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/fetchEmojis', {})
|
||||
expect(store.state.TimelineSpace.emojis).toEqual([emacsEmoji, rubyEmoji])
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchInstance', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/fetchInstance', {})
|
||||
expect(store.state.TimelineSpace.tootMax).toEqual(mockedInstance.max_toot_chars)
|
||||
})
|
||||
})
|
||||
|
||||
describe('loadUnreadNotification', () => {
|
||||
describe('success', () => {
|
||||
it('should be updated', async () => {
|
||||
ipcMain.handle('get-account-setting', () => {
|
||||
return {
|
||||
accountID: 'sample',
|
||||
timeline: {
|
||||
unreadNotification: {
|
||||
direct: false,
|
||||
local: false,
|
||||
public: false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
await store.dispatch('TimelineSpace/loadTimelineSetting')
|
||||
expect(store.state.TimelineSpace.timelineSetting).toEqual({
|
||||
unreadNotification: {
|
||||
direct: false,
|
||||
local: false,
|
||||
public: false
|
||||
}
|
||||
})
|
||||
ipcMain.removeHandler('get-account-setting')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchContentsTimelines', () => {
|
||||
it('should be called', async () => {
|
||||
await store.dispatch('TimelineSpace/fetchContentsTimelines', {})
|
||||
expect(homeStore.actions.fetchTimeline).toHaveBeenCalled()
|
||||
expect(notificationStore.actions.fetchNotifications).toHaveBeenCalled()
|
||||
expect(DMStore.actions.fetchTimeline).toHaveBeenCalled()
|
||||
expect(LocalStore.actions.fetchLocalTimeline).toHaveBeenCalled()
|
||||
expect(PublicStore.actions.fetchPublicTimeline).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,228 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import DirectMessages, { DirectMessagesState } from '@/store/TimelineSpace/Contents/DirectMessages'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getConversationTimeline: () => {
|
||||
return new Promise<Response<Array<Entity.Conversation>>>(resolve => {
|
||||
const res: Response<Array<Entity.Conversation>> = {
|
||||
data: [conversation1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const conversation1: Entity.Conversation = {
|
||||
id: '1',
|
||||
accounts: [account],
|
||||
last_status: status1,
|
||||
unread: false
|
||||
}
|
||||
|
||||
const conversation2: Entity.Conversation = {
|
||||
id: '2',
|
||||
accounts: [account],
|
||||
last_status: status2,
|
||||
unread: false
|
||||
}
|
||||
|
||||
let state = (): DirectMessagesState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: DirectMessages.actions,
|
||||
mutations: DirectMessages.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
DirectMessages: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/DirectMessages/fetchTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.DirectMessages.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchTimeline', () => {
|
||||
describe('success', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status1]
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getConversationTimeline = () => {
|
||||
return new Promise<Response<Array<Entity.Conversation>>>(resolve => {
|
||||
const res: Response<Array<Entity.Conversation>> = {
|
||||
data: [conversation2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
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,321 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
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: () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const localAccount: LocalAccount = {
|
||||
_id: '1',
|
||||
baseURL: 'http://localhost',
|
||||
domain: 'localhost',
|
||||
clientId: 'id',
|
||||
clientSecret: 'secret',
|
||||
accessToken: 'token',
|
||||
refreshToken: null,
|
||||
username: 'hoge',
|
||||
accountId: '1',
|
||||
avatar: null,
|
||||
order: 1
|
||||
}
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
let state = (): FavouritesState => {
|
||||
return {
|
||||
favourites: [],
|
||||
lazyLoading: false,
|
||||
maxId: null
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Favourites.actions,
|
||||
mutations: Favourites.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Favourites: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Favourites', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchFavourites', () => {
|
||||
it('does not exist header', async () => {
|
||||
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 () => {
|
||||
mockClient.getFavourites = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {
|
||||
link: null
|
||||
}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
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 () => {
|
||||
mockClient.getFavourites = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {
|
||||
link: '<http://localhost?max_id=2>; rel="next"'
|
||||
}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
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')
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchFavourites', () => {
|
||||
describe('lazyLoading', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
favourites: [],
|
||||
lazyLoading: true,
|
||||
maxId: null
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should not be updated', async () => {
|
||||
const res = await store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites')
|
||||
expect(res).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('does not exist maxId', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
favourites: [],
|
||||
lazyLoading: false,
|
||||
maxId: null
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should not be updated', async () => {
|
||||
const res = await store.dispatch('TimelineSpace/Contents/Favourites/lazyFetchFavourites')
|
||||
expect(res).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetch', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
favourites: [status1],
|
||||
lazyLoading: false,
|
||||
maxId: '2'
|
||||
}
|
||||
}
|
||||
})
|
||||
it('link is null', async () => {
|
||||
mockClient.getFavourites = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {
|
||||
link: null
|
||||
}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
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 () => {
|
||||
mockClient.getFavourites = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {
|
||||
link: '<http://localhost?max_id=3>; rel="next"'
|
||||
}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
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,221 +0,0 @@
|
|||
import { Entity, Response } from 'megalodon'
|
||||
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: () => {
|
||||
return new Promise<Response<Array<Entity.Account>>>(resolve => {
|
||||
const res: Response<Array<Entity.Account>> = {
|
||||
data: [account],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
},
|
||||
acceptFollowRequest: () => {
|
||||
return new Promise<Response<{}>>(resolve => {
|
||||
const res: Response<{}> = {
|
||||
data: {},
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
},
|
||||
rejectFollowRequest: () => {
|
||||
return new Promise<Response<{}>>(resolve => {
|
||||
const res: Response<{}> = {
|
||||
data: {},
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
let state = (): FollowRequestsState => {
|
||||
return {
|
||||
requests: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: FollowRequests.actions,
|
||||
mutations: FollowRequests.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const sideMenuState = (): SideMenuState => {
|
||||
return {
|
||||
unreadHomeTimeline: false,
|
||||
unreadNotifications: false,
|
||||
unreadMentions: false,
|
||||
unreadLocalTimeline: false,
|
||||
unreadDirectMessagesTimeline: false,
|
||||
unreadPublicTimeline: false,
|
||||
unreadFollowRequests: false,
|
||||
lists: [],
|
||||
tags: [],
|
||||
collapse: false,
|
||||
enabledTimelines: {
|
||||
home: true,
|
||||
notification: true,
|
||||
mention: true,
|
||||
direct: true,
|
||||
favourite: true,
|
||||
bookmark: true,
|
||||
local: true,
|
||||
public: true,
|
||||
tag: true,
|
||||
list: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sideMenuStore = () => ({
|
||||
namespaced: true,
|
||||
state: sideMenuState(),
|
||||
actions: {
|
||||
fetchFollowRequests: jest.fn()
|
||||
},
|
||||
mutations: {}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
FollowRequests: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
SideMenu: sideMenuStore(),
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchRequests', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/FollowRequests/fetchRequests')
|
||||
expect(store.state.TimelineSpace.Contents.FollowRequests.requests).toEqual([account])
|
||||
})
|
||||
})
|
||||
|
||||
describe('acceptRequest', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
requests: [account]
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be succeed', async () => {
|
||||
mockClient.getFollowRequests = () => {
|
||||
return new Promise<Response<Array<Entity.Account>>>(resolve => {
|
||||
const res: Response<Array<Entity.Account>> = {
|
||||
data: [],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
await store.dispatch('TimelineSpace/Contents/FollowRequests/acceptRequest', account)
|
||||
expect(store.state.TimelineSpace.Contents.FollowRequests.requests).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('rejectRequest', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
requests: [account]
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be succeed', async () => {
|
||||
mockClient.getFollowRequests = () => {
|
||||
return new Promise<Response<Array<Entity.Account>>>(resolve => {
|
||||
const res: Response<Array<Entity.Account>> = {
|
||||
data: [],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
await store.dispatch('TimelineSpace/Contents/FollowRequests/rejectRequest', account)
|
||||
expect(store.state.TimelineSpace.Contents.FollowRequests.requests).toEqual([])
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,96 +0,0 @@
|
|||
import { IpcMainInvokeEvent } from 'electron'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import List, { ListState } from '@/store/TimelineSpace/Contents/Hashtag/List'
|
||||
import { MyWindow } from '~/src/types/global'
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const tag1: LocalTag = {
|
||||
tagName: 'tag1',
|
||||
_id: '1'
|
||||
}
|
||||
|
||||
const tag2: LocalTag = {
|
||||
tagName: 'tag2',
|
||||
_id: '2'
|
||||
}
|
||||
|
||||
const state = (): ListState => {
|
||||
return {
|
||||
tags: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: List.actions,
|
||||
mutations: List.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const hashtagStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
List: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Hashtag: hashtagStore()
|
||||
}
|
||||
})
|
||||
|
||||
const sideMenuStore = {
|
||||
namespaced: true,
|
||||
actions: {
|
||||
listTags: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
SideMenu: sideMenuStore,
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
describe('Hashtag/List', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('listTags', () => {
|
||||
it('should be updated', async () => {
|
||||
ipcMain.handle('list-hashtags', () => {
|
||||
return [tag1, tag2]
|
||||
})
|
||||
afterEach(() => {
|
||||
ipcMain.removeHandler('list-hashtags')
|
||||
})
|
||||
await store.dispatch('TimelineSpace/Contents/Hashtag/List/listTags')
|
||||
expect(store.state.TimelineSpace.Contents.Hashtag.List.tags).toEqual([tag1, tag2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeTag', () => {
|
||||
it('should be updated', async () => {
|
||||
ipcMain.handle('remove-hashtag', (_: IpcMainInvokeEvent, tag: LocalTag) => {
|
||||
expect(tag).toEqual(tag1)
|
||||
})
|
||||
await store.dispatch('TimelineSpace/Contents/Hashtag/List/removeTag', tag1)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,225 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
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: () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
let state = (): TagState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Tag.actions,
|
||||
mutations: Tag.mutations
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetch', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Hashtag/Tag/fetch', 'tag')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Hashtag.Tag.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchTimeline', () => {
|
||||
describe('success', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status1],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getTagTimeline = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
const loadPositionWithTag: LoadPositionWithTag = {
|
||||
status: status1,
|
||||
tag: 'tag'
|
||||
}
|
||||
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,224 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Home, { HomeState } from '@/store/TimelineSpace/Contents/Home'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getHomeTimeline: () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
let state = (): HomeState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [],
|
||||
unreads: [],
|
||||
showReblogs: true,
|
||||
showReplies: true
|
||||
}
|
||||
}
|
||||
|
||||
const homeStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Home.actions,
|
||||
mutations: Home.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Home: homeStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
timelineSetting: {
|
||||
useMarker: {
|
||||
home: false,
|
||||
notifications: false
|
||||
}
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Home/fetchTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Home.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchTimeline', () => {
|
||||
describe('success', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status1],
|
||||
unreads: [],
|
||||
showReblogs: true,
|
||||
showReplies: true
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getHomeTimeline = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
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,139 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
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: () => {
|
||||
return new Promise<Response<Entity.Account[]>>(resolve => {
|
||||
const res: Response<Entity.Account[]> = {
|
||||
data: [account],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
},
|
||||
deleteAccountsFromList: () => {
|
||||
return new Promise<Response<{}>>(resolve => {
|
||||
const res: Response<{}> = {
|
||||
data: {},
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const state = (): EditState => {
|
||||
return {
|
||||
members: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Edit.actions,
|
||||
mutations: Edit.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const listsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Edit: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Lists: listsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Lists/Edit', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchMembers', () => {
|
||||
it('should get', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/Lists/Edit/fetchMembers', 'id')
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Edit.members).toEqual([account])
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeAccount', () => {
|
||||
it('should be removed', async () => {
|
||||
const removeFromList: RemoveAccountFromList = {
|
||||
account: account,
|
||||
listId: 'id'
|
||||
}
|
||||
const res = await store.dispatch('TimelineSpace/Contents/Lists/Edit/removeAccount', removeFromList)
|
||||
expect(res.data).toEqual({})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,117 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Index, { IndexState } from '@/store/TimelineSpace/Contents/Lists/Index'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getLists: () => {
|
||||
return new Promise<Response<Array<Entity.List>>>(resolve => {
|
||||
const res: Response<Array<Entity.List>> = {
|
||||
data: [list],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
},
|
||||
createList: () => {
|
||||
return new Promise<Response<Entity.List>>(resolve => {
|
||||
const res: Response<Entity.List> = {
|
||||
data: list,
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const list: Entity.List = {
|
||||
id: '1',
|
||||
title: 'list1'
|
||||
}
|
||||
|
||||
const state = (): IndexState => {
|
||||
return {
|
||||
lists: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Index.actions,
|
||||
mutations: Index.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const listsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Index: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Lists: listsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Lists/Index', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchLists', () => {
|
||||
it('should be updated', async () => {
|
||||
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('TimelineSpace/Contents/Lists/Index/createList', 'list1')
|
||||
expect(res.title).toEqual('list1')
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,225 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
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: () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
let state = (): ShowState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Show.actions,
|
||||
mutations: Show.mutations
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Lists/Show', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/Lists/Show/fetchTimeline', '1')
|
||||
expect(store.state.TimelineSpace.Contents.Lists.Show.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchTimeline', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status1],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getListTimeline = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
const loadPosition: LoadPositionWithList = {
|
||||
status: status1,
|
||||
list_id: '1'
|
||||
}
|
||||
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,214 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Local, { LocalState } from '@/store/TimelineSpace/Contents/Local'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getLocalTimeline: () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
let state = (): LocalState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Local.actions,
|
||||
mutations: Local.mutations
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchLocalTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Local.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchTimeline', () => {
|
||||
describe('success', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status1],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getLocalTimeline = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
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,248 +0,0 @@
|
|||
import { RootState } from '@/store'
|
||||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Mentions from '~/src/renderer/store/TimelineSpace/Contents/Mentions'
|
||||
|
||||
const mockClient = {
|
||||
getNotifications: () => {
|
||||
return new Promise<Response<Entity.Notification[]>>(resolve => {
|
||||
const res: Response<Entity.Notification[]> = {
|
||||
data: [mention, reblog, favourite, follow],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const status: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const mention: Entity.Notification = {
|
||||
account: account,
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
id: '1',
|
||||
status: status,
|
||||
type: 'mention'
|
||||
}
|
||||
|
||||
const reblog: Entity.Notification = {
|
||||
account: account,
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
id: '2',
|
||||
status: status,
|
||||
type: 'reblog'
|
||||
}
|
||||
|
||||
const favourite: Entity.Notification = {
|
||||
account: account,
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
id: '3',
|
||||
status: status,
|
||||
type: 'favourite'
|
||||
}
|
||||
|
||||
const follow: Entity.Notification = {
|
||||
account: account,
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
id: '4',
|
||||
type: 'follow'
|
||||
}
|
||||
|
||||
let state: Function = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
mentions: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Mentions.actions,
|
||||
mutations: Mentions.mutations,
|
||||
getters: Mentions.getters
|
||||
}
|
||||
}
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Mentions: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
timelineSetting: {
|
||||
useMarker: {
|
||||
home: false,
|
||||
notifications: false,
|
||||
mentions: false
|
||||
}
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Mentions', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchMentions', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/Mentions/fetchMentions')
|
||||
expect(store.state.TimelineSpace.Contents.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchMentions', () => {
|
||||
describe('loading', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: true,
|
||||
heading: true,
|
||||
mentions: []
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should not be updated', async () => {
|
||||
const result = await store.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', {})
|
||||
expect(result).toEqual(null)
|
||||
})
|
||||
})
|
||||
|
||||
describe('success', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
mentions: [mention, reblog]
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getNotifications = () => {
|
||||
return new Promise<Response<Entity.Notification[]>>(resolve => {
|
||||
const res: Response<Entity.Notification[]> = {
|
||||
data: [favourite, follow],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('mentions', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
mentions: [mention, favourite, reblog, follow]
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should return only mentions', () => {
|
||||
const mentions = store.getters['TimelineSpace/Contents/Mentions/mentions']
|
||||
expect(mentions).toEqual([mention])
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,293 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Notifications, { NotificationsState } from '@/store/TimelineSpace/Contents/Notifications'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getNotifications: () => {
|
||||
return new Promise<Response<Array<Entity.Notification>>>(resolve => {
|
||||
const res: Response<Array<Entity.Notification>> = {
|
||||
data: [notification1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account1: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const account2: Entity.Account = {
|
||||
id: '2',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@mstdn.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://mstdn.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account1,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account1,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const rebloggedStatus: Entity.Status = {
|
||||
id: '3',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account1,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: status2,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const notification1: Entity.Notification = {
|
||||
id: '1',
|
||||
account: account2,
|
||||
status: status1,
|
||||
type: 'favourite',
|
||||
created_at: '2019-04-01T17:01:32'
|
||||
}
|
||||
|
||||
const notification2: Entity.Notification = {
|
||||
id: '2',
|
||||
account: account2,
|
||||
status: rebloggedStatus,
|
||||
type: 'mention',
|
||||
created_at: '2019-04-01T17:01:32'
|
||||
}
|
||||
|
||||
let state = (): NotificationsState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
notifications: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Notifications.actions,
|
||||
mutations: Notifications.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Notifications: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
timelineSetting: {
|
||||
useMarker: {
|
||||
home: false,
|
||||
notifications: false,
|
||||
mentions: false
|
||||
}
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false,
|
||||
useMarkerTimeline: []
|
||||
}
|
||||
}
|
||||
|
||||
describe('Notifications', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchNotifications', () => {
|
||||
it('should be updated', async () => {
|
||||
const response = await store.dispatch('TimelineSpace/Contents/Notifications/fetchNotifications')
|
||||
expect(response).toEqual([notification1])
|
||||
expect(store.state.TimelineSpace.Contents.Notifications.notifications).toEqual([notification1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchNotifications', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
notifications: [notification1]
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getNotifications = () => {
|
||||
return new Promise<Response<Array<Entity.Notification>>>(resolve => {
|
||||
const res: Response<Array<Entity.Notification>> = {
|
||||
data: [notification2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
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,213 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Public, { PublicState } from '@/store/TimelineSpace/Contents/Public'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
getPublicTimeline: () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status1],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
const status1: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
const status2: Entity.Status = {
|
||||
id: '2',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'fuga',
|
||||
plain_content: 'fuga',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
let state = (): PublicState => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Public.actions,
|
||||
mutations: Public.mutations
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Home', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('fetchPublicTimeline', () => {
|
||||
it('should be updated', async () => {
|
||||
const statuses = await store.dispatch('TimelineSpace/Contents/Public/fetchPublicTimeline')
|
||||
expect(statuses).toEqual([status1])
|
||||
expect(store.state.TimelineSpace.Contents.Public.timeline).toEqual([status1])
|
||||
})
|
||||
})
|
||||
|
||||
describe('lazyFetchTimeline', () => {
|
||||
describe('success', () => {
|
||||
beforeAll(() => {
|
||||
state = () => {
|
||||
return {
|
||||
lazyLoading: false,
|
||||
heading: true,
|
||||
timeline: [status1],
|
||||
unreads: []
|
||||
}
|
||||
}
|
||||
})
|
||||
it('should be updated', async () => {
|
||||
mockClient.getPublicTimeline = () => {
|
||||
return new Promise<Response<Array<Entity.Status>>>(resolve => {
|
||||
const res: Response<Array<Entity.Status>> = {
|
||||
data: [status2],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
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,121 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import AccountStore, { AccountState } from '@/store/TimelineSpace/Contents/Search/Account'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const mockClient = {
|
||||
searchAccount: () => {
|
||||
return new Promise<Response<Array<Entity.Account>>>(resolve => {
|
||||
const res: Response<Array<Entity.Account>> = {
|
||||
data: [account],
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const state = (): AccountState => {
|
||||
return {
|
||||
results: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: AccountStore.actions,
|
||||
mutations: AccountStore.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const searchStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Account: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {
|
||||
changeLoading: jest.fn()
|
||||
},
|
||||
actions: {},
|
||||
modules: {
|
||||
Search: searchStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Search/Account', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('search', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/Search/Account/search', 'query')
|
||||
expect(store.state.TimelineSpace.Contents.Search.Account.results).toEqual([account])
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,109 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import TagStore, { TagState } from '@/store/TimelineSpace/Contents/Search/Tag'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const tag1: Entity.Tag = {
|
||||
name: 'tag1',
|
||||
url: 'http://example.com/tag1',
|
||||
history: null
|
||||
}
|
||||
|
||||
const mockClient = {
|
||||
search: () => {
|
||||
return new Promise<Response<Entity.Results>>(resolve => {
|
||||
const res: Response<Entity.Results> = {
|
||||
data: {
|
||||
accounts: [],
|
||||
statuses: [],
|
||||
hashtags: [tag1]
|
||||
},
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const state = (): TagState => {
|
||||
return {
|
||||
results: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: TagStore.actions,
|
||||
mutations: TagStore.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const searchStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Tag: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {
|
||||
changeLoading: jest.fn()
|
||||
},
|
||||
actions: {},
|
||||
modules: {
|
||||
Search: searchStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Search/Tag', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('search', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/Search/Tag/search', 'query')
|
||||
expect(store.state.TimelineSpace.Contents.Search.Tag.results).toEqual([tag1])
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,161 +0,0 @@
|
|||
import { Response, Entity } from 'megalodon'
|
||||
import { createStore, Store } from 'vuex'
|
||||
import Toots, { TootsState } from '@/store/TimelineSpace/Contents/Search/Toots'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const mockClient = {
|
||||
search: () => {
|
||||
return new Promise<Response<Entity.Results>>(resolve => {
|
||||
const res: Response<Entity.Results> = {
|
||||
data: {
|
||||
accounts: [],
|
||||
statuses: [status],
|
||||
hashtags: []
|
||||
},
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: {}
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
jest.mock('megalodon', () => ({
|
||||
...jest.requireActual<object>('megalodon'),
|
||||
default: jest.fn(() => mockClient),
|
||||
__esModule: true
|
||||
}))
|
||||
|
||||
const account: Entity.Account = {
|
||||
id: '1',
|
||||
username: 'h3poteto',
|
||||
acct: 'h3poteto@pleroma.io',
|
||||
display_name: 'h3poteto',
|
||||
locked: false,
|
||||
created_at: '2019-03-26T21:30:32',
|
||||
followers_count: 10,
|
||||
following_count: 10,
|
||||
statuses_count: 100,
|
||||
note: 'engineer',
|
||||
url: 'https://pleroma.io',
|
||||
avatar: '',
|
||||
avatar_static: '',
|
||||
header: '',
|
||||
header_static: '',
|
||||
emojis: [],
|
||||
moved: null,
|
||||
fields: null,
|
||||
bot: false
|
||||
}
|
||||
|
||||
const status: Entity.Status = {
|
||||
id: '1',
|
||||
uri: 'http://example.com',
|
||||
url: 'http://example.com',
|
||||
account: account,
|
||||
in_reply_to_id: null,
|
||||
in_reply_to_account_id: null,
|
||||
reblog: null,
|
||||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
favourites_count: 0,
|
||||
reblogged: null,
|
||||
favourited: null,
|
||||
muted: null,
|
||||
sensitive: false,
|
||||
spoiler_text: '',
|
||||
visibility: 'public',
|
||||
media_attachments: [],
|
||||
mentions: [],
|
||||
tags: [],
|
||||
card: null,
|
||||
poll: null,
|
||||
application: {
|
||||
name: 'Web'
|
||||
} as Entity.Application,
|
||||
language: null,
|
||||
pinned: null,
|
||||
emoji_reactions: [],
|
||||
bookmarked: false,
|
||||
quote: false
|
||||
}
|
||||
|
||||
const state = (): TootsState => {
|
||||
return {
|
||||
results: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: Toots.actions,
|
||||
mutations: Toots.mutations
|
||||
}
|
||||
}
|
||||
|
||||
const searchStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Toots: initStore()
|
||||
}
|
||||
})
|
||||
|
||||
const contentsStore = () => ({
|
||||
namespaced: true,
|
||||
state: {},
|
||||
mutations: {
|
||||
changeLoading: jest.fn()
|
||||
},
|
||||
actions: {},
|
||||
modules: {
|
||||
Search: searchStore()
|
||||
}
|
||||
})
|
||||
|
||||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
modules: {
|
||||
Contents: contentsStore()
|
||||
},
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
}
|
||||
})
|
||||
|
||||
const appState = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
proxyConfiguration: false
|
||||
}
|
||||
}
|
||||
|
||||
describe('Search/Account', () => {
|
||||
let store: Store<RootState>
|
||||
|
||||
beforeEach(() => {
|
||||
store = createStore({
|
||||
modules: {
|
||||
TimelineSpace: timelineStore(),
|
||||
App: appState
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('search', () => {
|
||||
it('should be updated', async () => {
|
||||
await store.dispatch('TimelineSpace/Contents/Search/Toots/search', 'query')
|
||||
expect(store.state.TimelineSpace.Contents.Search.Toots.results).toEqual([status])
|
||||
})
|
||||
})
|
||||
})
|
|
@ -40,16 +40,13 @@ const timelineStore = (account: Entity.Account | null) => ({
|
|||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
baseURL: 'https://example.com',
|
||||
domain: 'example.com',
|
||||
clientId: 'sampleId',
|
||||
clientSecret: 'sampleSecret',
|
||||
accessToken: 'sampleAccessToken',
|
||||
refreshToken: null,
|
||||
username: 'h3poteto',
|
||||
accountID: '1',
|
||||
avatar: null,
|
||||
order: 1
|
||||
id: 1,
|
||||
username: 'h3poteto'
|
||||
},
|
||||
server: {
|
||||
sns: 'mastodon',
|
||||
baseURL: 'https://example.com'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
|
|
|
@ -49,10 +49,12 @@ const timelineStore = () => ({
|
|||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
accessToken: 'token',
|
||||
baseURL: 'http://localhost'
|
||||
accessToken: 'token'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
server: {
|
||||
sns: 'mastodon',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
HeaderMenu: initStore()
|
||||
|
|
|
@ -84,9 +84,12 @@ const timelineStore = () => ({
|
|||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
_id: '0'
|
||||
id: 0,
|
||||
accessToken: 'token'
|
||||
},
|
||||
sns: 'mastodon'
|
||||
server: {
|
||||
sns: 'mastodon'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
Modals: modalsStore()
|
||||
|
|
|
@ -70,7 +70,7 @@ const timelineStore = () => ({
|
|||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
_id: '0'
|
||||
id: 0
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
|
|
|
@ -130,7 +130,12 @@ const timelineStore = () => ({
|
|||
namespaced: true,
|
||||
state: {
|
||||
account: {
|
||||
_id: '0'
|
||||
id: 0,
|
||||
accessToken: 'token'
|
||||
},
|
||||
server: {
|
||||
sns: 'mastodon',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
|
|
|
@ -2,10 +2,9 @@ import { Entity, Response } from 'megalodon'
|
|||
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'
|
||||
import { RootState } from '@/store'
|
||||
;(window as any as MyWindow).ipcRenderer = ipcRenderer
|
||||
;((window as any) as MyWindow).ipcRenderer = ipcRenderer
|
||||
|
||||
const mockClient = {
|
||||
getLists: () => {
|
||||
|
@ -85,7 +84,14 @@ const appStore = {
|
|||
const timelineStore = () => ({
|
||||
namespaced: true,
|
||||
state: {
|
||||
sns: 'mastodon'
|
||||
account: {
|
||||
id: 0,
|
||||
accessToken: 'token'
|
||||
},
|
||||
server: {
|
||||
sns: 'mastodon',
|
||||
baseURL: 'http://localhost'
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
SideMenu: initStore()
|
||||
|
@ -145,20 +151,4 @@ describe('SideMenu', () => {
|
|||
expect(store.state.TimelineSpace.SideMenu.collapse).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('listTags', () => {
|
||||
it('should be listed', async () => {
|
||||
const tag1: LocalTag = {
|
||||
tagName: 'tag1'
|
||||
}
|
||||
const tag2: LocalTag = {
|
||||
tagName: 'tag2'
|
||||
}
|
||||
ipcMain.handle('list-hashtags', () => {
|
||||
return [tag1, tag2]
|
||||
})
|
||||
await store.dispatch('TimelineSpace/SideMenu/listTags')
|
||||
expect(store.state.TimelineSpace.SideMenu.tags).toEqual([tag1, tag2])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -5,15 +5,17 @@ describe('Login', () => {
|
|||
let state: LoginState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
selectedInstance: null,
|
||||
domain: null,
|
||||
searching: false,
|
||||
server: null,
|
||||
appData: null,
|
||||
sns: 'mastodon'
|
||||
}
|
||||
})
|
||||
describe('changeInstance', () => {
|
||||
it('should be changed', () => {
|
||||
Login.mutations![MUTATION_TYPES.CHANGE_INSTANCE](state, 'pleroma.io')
|
||||
expect(state.selectedInstance).toEqual('pleroma.io')
|
||||
Login.mutations![MUTATION_TYPES.CHANGE_DOMAIN](state, 'pleroma.io')
|
||||
expect(state.domain).toEqual('pleroma.io')
|
||||
})
|
||||
})
|
||||
describe('changeSearching', () => {
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import Account, { AccountState, MUTATION_TYPES } from '@/store/Preferences/Account'
|
||||
import { LocalAccount } from '~/src/types/localAccount'
|
||||
|
||||
const account: LocalAccount = {
|
||||
_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('mutations', () => {
|
||||
let state: AccountState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
accounts: [],
|
||||
accountLoading: false
|
||||
}
|
||||
})
|
||||
describe('updateAccounts', () => {
|
||||
it('should be updated', () => {
|
||||
Account.mutations![MUTATION_TYPES.UPDATE_ACCOUNTS](state, [account])
|
||||
expect(state.accounts).toEqual([account])
|
||||
})
|
||||
})
|
||||
describe('updateAccountLoading', () => {
|
||||
it('should be update', () => {
|
||||
Account.mutations![MUTATION_TYPES.UPDATE_ACCOUNT_LOADING](state, true)
|
||||
expect(state.accountLoading).toEqual(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,40 +0,0 @@
|
|||
import Theme from '~/src/constants/theme'
|
||||
import DisplayStyle from '~/src/constants/displayStyle'
|
||||
import TimeFormat from '~/src/constants/timeFormat'
|
||||
import { LightTheme } from '~/src/constants/themeColor'
|
||||
import DefaultFonts from '@/utils/fonts'
|
||||
import Appearance, { AppearanceState, MUTATION_TYPES } from '@/store/Preferences/Appearance'
|
||||
|
||||
describe('Preferences/Appearance', () => {
|
||||
let state: AppearanceState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
appearance: {
|
||||
theme: Theme.Light.key,
|
||||
fontSize: 14,
|
||||
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
|
||||
timeFormat: TimeFormat.Absolute.value,
|
||||
customThemeColor: LightTheme,
|
||||
font: DefaultFonts[0],
|
||||
tootPadding: 8
|
||||
},
|
||||
fonts: []
|
||||
}
|
||||
})
|
||||
describe('mutations', () => {
|
||||
describe('updateAppearance', () => {
|
||||
it('should be changed', () => {
|
||||
Appearance.mutations![MUTATION_TYPES.UPDATE_APPEARANCE](state, {
|
||||
theme: Theme.Dark.key
|
||||
})
|
||||
expect(state.appearance.theme).toEqual(Theme.Dark.key)
|
||||
})
|
||||
})
|
||||
describe('updateFonts', () => {
|
||||
it('should be changed', () => {
|
||||
Appearance.mutations![MUTATION_TYPES.UPDATE_FONTS](state, ['font'])
|
||||
expect(state.fonts).toEqual(['font'])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,38 +0,0 @@
|
|||
import General, { GeneralState, MUTATION_TYPES } from '@/store/Preferences/General'
|
||||
|
||||
describe('Preferences/General', () => {
|
||||
let state: GeneralState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
general: {
|
||||
sound: {
|
||||
fav_rb: true,
|
||||
toot: true
|
||||
},
|
||||
timeline: {
|
||||
cw: false,
|
||||
nsfw: false,
|
||||
hideAllAttachments: false
|
||||
},
|
||||
other: {
|
||||
launch: false,
|
||||
hideOnLaunch: false
|
||||
}
|
||||
},
|
||||
loading: false
|
||||
}
|
||||
})
|
||||
|
||||
describe('mutations', () => {
|
||||
it('updateGeneral', () => {
|
||||
General.mutations![MUTATION_TYPES.UPDATE_GENERAL](state, {
|
||||
sound: {
|
||||
fav_rb: false,
|
||||
toot: false
|
||||
}
|
||||
})
|
||||
expect(state.general.sound.fav_rb).toEqual(false)
|
||||
expect(state.general.sound.toot).toEqual(false)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,33 +0,0 @@
|
|||
import Language, { LanguageState, MUTATION_TYPES } from '@/store/Preferences/Language'
|
||||
import DefaultLanguage from '~/src/constants/language'
|
||||
|
||||
describe('Preferences/Language', () => {
|
||||
let state: LanguageState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
language: {
|
||||
language: DefaultLanguage.en.key,
|
||||
spellchecker: {
|
||||
enabled: true,
|
||||
languages: []
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
describe('mutations', () => {
|
||||
describe('updateLanguage', () => {
|
||||
it('should be updated', () => {
|
||||
Language.mutations![MUTATION_TYPES.UPDATE_LANGUAGE](state, {
|
||||
language: DefaultLanguage.ja.key
|
||||
})
|
||||
expect(state.language.language).toEqual(DefaultLanguage.ja.key)
|
||||
})
|
||||
})
|
||||
describe('changeLanguage', () => {
|
||||
it('should be changed', () => {
|
||||
Language.mutations![MUTATION_TYPES.CHANGE_LANGUAGE](state, DefaultLanguage.ja.key)
|
||||
expect(state.language.language).toEqual(DefaultLanguage.ja.key)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,50 +0,0 @@
|
|||
import Notification, { NotificationState, MUTATION_TYPES } from '@/store/Preferences/Notification'
|
||||
|
||||
describe('Preferences/Notification', () => {
|
||||
let state: NotificationState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
notification: {
|
||||
notify: {
|
||||
reply: true,
|
||||
reblog: true,
|
||||
favourite: true,
|
||||
follow: true,
|
||||
follow_request: true,
|
||||
reaction: true,
|
||||
status: true,
|
||||
poll_vote: true,
|
||||
poll_expired: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
describe('mutations', () => {
|
||||
it('updateNotification', () => {
|
||||
Notification.mutations![MUTATION_TYPES.UPDATE_NOTIFICATION](state, {
|
||||
notify: {
|
||||
reply: false,
|
||||
reblog: false,
|
||||
favourite: false,
|
||||
follow: false,
|
||||
follow_request: false,
|
||||
reaction: false,
|
||||
status: false,
|
||||
poll_vote: false,
|
||||
poll_expired: false
|
||||
}
|
||||
})
|
||||
expect(state.notification.notify).toEqual({
|
||||
reply: false,
|
||||
reblog: false,
|
||||
favourite: false,
|
||||
follow: false,
|
||||
follow_request: false,
|
||||
reaction: false,
|
||||
status: false,
|
||||
poll_vote: false,
|
||||
poll_expired: false
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
|
@ -1,4 +1,4 @@
|
|||
import TimelineSpace, { TimelineSpaceState, blankAccount, MUTATION_TYPES } from '~/src/renderer/store/TimelineSpace'
|
||||
import TimelineSpace, { TimelineSpaceState, MUTATION_TYPES } from '~/src/renderer/store/TimelineSpace'
|
||||
import { DefaultSetting } from '~/src/constants/initializer/setting'
|
||||
|
||||
describe('TimelineSpace', () => {
|
||||
|
@ -6,13 +6,12 @@ describe('TimelineSpace', () => {
|
|||
let state: TimelineSpaceState
|
||||
beforeEach(() => {
|
||||
state = {
|
||||
account: blankAccount,
|
||||
bindingAccount: null,
|
||||
account: null,
|
||||
server: null,
|
||||
loading: false,
|
||||
emojis: [],
|
||||
tootMax: 500,
|
||||
timelineSetting: DefaultSetting.timeline,
|
||||
sns: 'mastodon',
|
||||
setting: DefaultSetting,
|
||||
filters: []
|
||||
}
|
||||
})
|
||||
|
|
|
@ -88,10 +88,14 @@ describe('TimelineSpace/Modals/Jump', () => {
|
|||
describe('updateTagChannel', () => {
|
||||
it('should be updated', () => {
|
||||
const whalebird: LocalTag = {
|
||||
tagName: 'whalebird'
|
||||
tagName: 'whalebird',
|
||||
id: 0,
|
||||
accountId: 1
|
||||
}
|
||||
const tqrk: LocalTag = {
|
||||
tagName: 'tqrk'
|
||||
tagName: 'tqrk',
|
||||
id: 0,
|
||||
accountId: 1
|
||||
}
|
||||
const channelList = [whalebird, tqrk]
|
||||
Jump.mutations![MUTATION_TYPES.UPDATE_TAG_CHANNEL](state, channelList)
|
||||
|
|
Loading…
Reference in New Issue