From 4dceedb3ef384b9c8a8e3b0fccec3de4ab501dd9 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 15 Mar 2020 17:48:02 +0900
Subject: [PATCH] Fix megalodon class for 3.0.0 in spec
---
spec/mock/megalodon.ts | 10 --
spec/renderer/integration/store/Login.spec.ts | 57 +------
.../integration/store/TimelineSpace.spec.ts | 152 ++++++-----------
.../Contents/DirectMessages.spec.ts | 79 +++++----
.../TimelineSpace/Contents/Favourites.spec.ts | 153 ++++++++----------
.../Contents/FollowRequests.spec.ts | 134 ++++++++-------
.../Contents/Hashtag/Tag.spec.ts | 72 ++++-----
.../store/TimelineSpace/Contents/Home.spec.ts | 73 +++++----
.../TimelineSpace/Contents/Lists/Edit.spec.ts | 72 ++++-----
.../Contents/Lists/Index.spec.ts | 72 ++++-----
.../TimelineSpace/Contents/Lists/Show.spec.ts | 72 ++++-----
.../TimelineSpace/Contents/Local.spec.ts | 73 +++++----
.../TimelineSpace/Contents/Mentions.spec.ts | 77 +++++----
.../Contents/Notifications.spec.ts | 82 +++++-----
.../TimelineSpace/Contents/Public.spec.ts | 72 ++++-----
.../Contents/Search/Account.spec.ts | 46 +++---
.../TimelineSpace/Contents/Search/Tag.spec.ts | 56 +++----
.../Contents/Search/Toots.spec.ts | 56 +++----
.../Contents/SideBar/AccountProfile.spec.ts | 14 +-
.../store/TimelineSpace/HeaderMenu.spec.ts | 46 +++---
.../Modals/AddListMember.spec.ts | 70 ++++----
.../Modals/ListMembership.spec.ts | 117 +++++++-------
.../store/TimelineSpace/SideMenu.spec.ts | 59 ++++---
.../renderer/unit/store/TimelineSpace.spec.ts | 2 +-
.../Contents/DirectMessages.spec.ts | 16 +-
.../Contents/Hashtag/Tag.spec.ts | 16 +-
.../store/TimelineSpace/Contents/Home.spec.ts | 24 +--
.../TimelineSpace/Contents/Lists/Show.spec.ts | 16 +-
.../TimelineSpace/Contents/Local.spec.ts | 16 +-
.../TimelineSpace/Contents/Mentions.spec.ts | 24 +--
.../Contents/Notifications.spec.ts | 22 +--
.../TimelineSpace/Contents/Public.spec.ts | 16 +-
.../store/TimelineSpace/Modals/Jump.spec.ts | 8 +-
33 files changed, 876 insertions(+), 998 deletions(-)
delete mode 100644 spec/mock/megalodon.ts
diff --git a/spec/mock/megalodon.ts b/spec/mock/megalodon.ts
deleted file mode 100644
index f5e9e86b..00000000
--- a/spec/mock/megalodon.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import Mastodon, { MegalodonInstance } from 'megalodon'
-
-interface MockedMegalodon extends MegalodonInstance {
- mockResolvedValue: Function
- mockImplementation: Function
- mockClear: Function
-}
-
-const mockedMegalodon: jest.Mocked = Mastodon as any
-export default mockedMegalodon
diff --git a/spec/renderer/integration/store/Login.spec.ts b/spec/renderer/integration/store/Login.spec.ts
index 7b8d6adf..6e871b83 100644
--- a/spec/renderer/integration/store/Login.spec.ts
+++ b/spec/renderer/integration/store/Login.spec.ts
@@ -1,12 +1,15 @@
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
-import Mastodon, { Instance, Response } from 'megalodon'
import Login, { LoginState } from '@/store/Login'
import { MyWindow } from '~/src/types/global'
;(window as MyWindow).ipcRenderer = ipcRenderer
-jest.mock('megalodon')
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ detector: jest.fn(() => 'pleroma'),
+ __esModule: true
+}))
const state = (): LoginState => {
return {
@@ -77,56 +80,6 @@ describe('Login', () => {
describe('confirmInstance', () => {
it('should change instance', async () => {
- // Provide Promise.resolve for finally keywrod.
- // https://github.com/facebook/jest/issues/6552
- // https://github.com/kulshekhar/ts-jest/issues/828
- const mockedClient = Mastodon as any
- const instance: Promise> = new Promise>(resolve => {
- const res: Response = {
- data: {
- uri: 'http://example.com',
- title: 'test-mastodon',
- description: 'description',
- email: 'hoge@example.com',
- version: '1.0.0',
- thumbnail: null,
- urls: {
- streaming_api: 'http://example.com'
- },
- stats: {
- user_count: 1,
- status_count: 10,
- domain_count: 10
- },
- languages: ['en'],
- contact_account: null
- } as Instance,
- status: 200,
- statusText: '200',
- headers: null
- }
- resolve(res)
- })
- mockedClient.get.mockImplementation(() => instance)
- const result = await store.dispatch('Login/confirmInstance', 'pleroma.io')
- expect(result).toEqual(true)
- expect(store.state.Login.selectedInstance).toEqual('pleroma.io')
- })
-
- it('should failover host-meta', async () => {
- const mockedClient = Mastodon as any
- // @ts-ignore
- const instance: Promise = new Promise((resolve, reject) => {
- const err = new Error('err')
- reject(err)
- })
- const hostMeta: Promise<{}> = new Promise<{}>(resolve => {
- resolve({
- data:
- ''
- })
- })
- mockedClient.get.mockImplementationOnce(() => instance).mockImplementationOnce(() => hostMeta)
const result = await store.dispatch('Login/confirmInstance', 'pleroma.io')
expect(result).toEqual(true)
expect(store.state.Login.selectedInstance).toEqual('pleroma.io')
diff --git a/spec/renderer/integration/store/TimelineSpace.spec.ts b/spec/renderer/integration/store/TimelineSpace.spec.ts
index 2ec6b2da..7159ebb2 100644
--- a/spec/renderer/integration/store/TimelineSpace.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace.spec.ts
@@ -1,4 +1,4 @@
-import Mastodon, { Emoji, Instance, Response } from 'megalodon'
+import { Entity, Response } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
@@ -7,9 +7,20 @@ import unreadSettings from '~/src/constants/unreadNotification'
import { MyWindow } from '~/src/types/global'
;(window as MyWindow).ipcRenderer = ipcRenderer
-jest.mock('megalodon')
+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: Instance = {
+const mockedInstance: Entity.Instance = {
uri: 'http://pleroma.io',
title: 'pleroma',
description: '',
@@ -29,6 +40,38 @@ const mockedInstance: Instance = {
max_toot_chars: 5000
}
+const mockClient = {
+ getInstance: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: mockedInstance,
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ getInstanceCustomEmojis: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [emacsEmoji, rubyEmoji],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
+
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ detector: jest.fn(() => 'pleroma'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
const state = (): TimelineSpaceState => {
return {
account: blankAccount,
@@ -41,7 +84,7 @@ const state = (): TimelineSpaceState => {
local: true,
public: true
},
- pleroma: false
+ sns: 'mastodon'
}
}
@@ -169,117 +212,26 @@ describe('TimelineSpace', () => {
})
})
- describe('detectPleroma', () => {
+ describe('detectSNS', () => {
describe('API is pleroma', () => {
- let mockedResponse: Response
- beforeEach(() => {
- mockedResponse = {
- data: mockedInstance,
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- })
it('should be detected', async () => {
- ;(Mastodon.get as any).mockResolvedValue(mockedResponse)
- await store.dispatch('TimelineSpace/detectPleroma')
- expect(store.state.TimelineSpace.pleroma).toEqual(true)
- })
- })
- describe('API is not pleroma', () => {
- let mockedResponse: Response
- beforeEach(() => {
- const instance: Instance = {
- uri: 'http://mstdn.io',
- title: 'mstnd.io',
- description: '',
- email: 'test@example.com',
- version: '2.7.0',
- thumbnail: null,
- urls: {
- streaming_api: 'wss://mstdn.io'
- },
- stats: {
- user_count: 10,
- status_count: 1000,
- domain_count: 100
- },
- languages: ['en'],
- contact_account: null
- }
- mockedResponse = {
- data: instance,
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- })
- it('should be detected', async () => {
- ;(Mastodon.get as any).mockResolvedValue(mockedResponse)
- await store.dispatch('TimelineSpace/detectPleroma')
- expect(store.state.TimelineSpace.pleroma).toEqual(false)
+ await store.dispatch('TimelineSpace/detectSNS')
+ expect(store.state.TimelineSpace.sns).toEqual('pleroma')
})
})
})
describe('fetchEmojis', () => {
- let emacsEmoji: Emoji
- let rubyEmoji: Emoji
- let mockedResponse: Response>
- beforeEach(() => {
- emacsEmoji = {
- shortcode: 'emacs',
- url: 'http://example.com/emacs',
- static_url: 'http://example.com/emacs',
- visible_in_picker: true
- }
- rubyEmoji = {
- shortcode: 'ruby',
- url: 'http://example.com/ruby',
- static_url: 'http://example.com/ruby',
- visible_in_picker: true
- }
- mockedResponse = {
- data: [emacsEmoji, rubyEmoji],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- })
it('should be updated', async () => {
- ;(Mastodon.get as any).mockResolvedValue(mockedResponse)
await store.dispatch('TimelineSpace/fetchEmojis', {})
- expect(store.state.TimelineSpace.emojis).toEqual([
- {
- shortcode: 'emacs',
- url: 'http://example.com/emacs',
- static_url: 'http://example.com/emacs',
- visible_in_picker: true
- },
- {
- shortcode: 'ruby',
- url: 'http://example.com/ruby',
- static_url: 'http://example.com/ruby',
- visible_in_picker: true
- }
- ])
+ expect(store.state.TimelineSpace.emojis).toEqual([emacsEmoji, rubyEmoji])
})
})
describe('fetchInstance', () => {
- let mockedResponse: Response
- beforeEach(() => {
- mockedResponse = {
- data: mockedInstance,
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- })
it('should be updated', async () => {
- ;(Mastodon.get as any).mockResolvedValue(mockedResponse)
await store.dispatch('TimelineSpace/fetchInstance', {})
- expect(store.state.TimelineSpace.tootMax).toEqual(5000)
+ expect(store.state.TimelineSpace.tootMax).toEqual(mockedInstance.max_toot_chars)
})
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts
index 2a177f0a..3653c7b6 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/DirectMessages.spec.ts
@@ -1,12 +1,29 @@
-import { Response, Status, Account, Application, Conversation } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import DirectMessages, { DirectMessagesState } from '@/store/TimelineSpace/Contents/DirectMessages'
-jest.mock('megalodon')
+const mockClient = {
+ getConversationTimeline: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [conversation1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,7 +45,7 @@ const account: Account = {
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -55,12 +72,12 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -87,19 +104,19 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const conversation1: Conversation = {
+const conversation1: Entity.Conversation = {
id: '1',
accounts: [account],
last_status: status1,
unread: false
}
-const conversation2: Conversation = {
+const conversation2: Entity.Conversation = {
id: '2',
accounts: [account],
last_status: status2,
@@ -131,7 +148,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -156,26 +174,10 @@ describe('Home', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchTimeline', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [conversation1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const statuses = await store.dispatch('DirectMessages/fetchTimeline')
expect(statuses).toEqual([status1])
expect(store.state.DirectMessages.timeline).toEqual([status1])
@@ -198,20 +200,17 @@ describe('Home', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [conversation2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getConversationTimeline = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [conversation2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('DirectMessages/lazyFetchTimeline', status1)
expect(store.state.DirectMessages.lazyLoading).toEqual(false)
expect(store.state.DirectMessages.timeline).toEqual([status1, status2])
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Favourites.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Favourites.spec.ts
index eff4469c..69423756 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Favourites.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Favourites.spec.ts
@@ -1,11 +1,28 @@
-import { Response, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Favourites, { FavouritesState } from '@/store/TimelineSpace/Contents/Favourites'
import { LocalAccount } from '~/src/types/localAccount'
-jest.mock('megalodon')
+const mockClient = {
+ getFavourites: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
+
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
const localAccount: LocalAccount = {
_id: '1',
@@ -21,7 +38,7 @@ const localAccount: LocalAccount = {
order: 1
}
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -42,7 +59,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -69,11 +86,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -100,7 +117,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -129,7 +146,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -154,72 +172,49 @@ describe('Favourites', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchFavourites', () => {
it('does not exist header', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Favourites/fetchFavourites', localAccount)
expect(store.state.Favourites.favourites).toEqual([status1])
expect(store.state.Favourites.maxId).toEqual(null)
})
it('link is null', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {
- link: null
- }
+ mockClient.getFavourites = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ link: null
}
- resolve(res)
- })
- }
+ }
+ resolve(res)
+ })
}
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Favourites/fetchFavourites', localAccount)
expect(store.state.Favourites.favourites).toEqual([status1])
expect(store.state.Favourites.maxId).toEqual(null)
})
it('link exists in header', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {
- link: '; rel="next"'
- }
+ mockClient.getFavourites = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ link: '; rel="next"'
}
- resolve(res)
- })
- }
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Favourites/fetchFavourites', localAccount)
expect(store.state.Favourites.favourites).toEqual([status1])
expect(store.state.Favourites.maxId).toEqual('2')
@@ -273,46 +268,40 @@ describe('Favourites', () => {
}
})
it('link is null', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {
- link: null
- }
+ mockClient.getFavourites = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ link: null
}
- resolve(res)
- })
- }
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Favourites/lazyFetchFavourites')
expect(store.state.Favourites.favourites).toEqual([status1, status2])
expect(store.state.Favourites.maxId).toEqual(null)
})
it('link exists in header', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {
- link: '; rel="next"'
- }
+ mockClient.getFavourites = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ link: '; rel="next"'
}
- resolve(res)
- })
- }
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Favourites/lazyFetchFavourites')
expect(store.state.Favourites.favourites).toEqual([status1, status2])
expect(store.state.Favourites.maxId).toEqual('3')
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/FollowRequests.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/FollowRequests.spec.ts
index 5c765a8b..5b273b46 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/FollowRequests.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/FollowRequests.spec.ts
@@ -1,13 +1,52 @@
-import { Account, Response } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Entity, Response } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import FollowRequests, { FollowRequestsState } from '@/store/TimelineSpace/Contents/FollowRequests'
import { SideMenuState } from '@/store/TimelineSpace/SideMenu'
-jest.mock('megalodon')
+const mockClient = {
+ getFollowRequests: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [account],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ acceptFollowRequest: () => {
+ return new Promise>(resolve => {
+ const res: Response<{}> = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ rejectFollowRequest: () => {
+ return new Promise>(resolve => {
+ const res: Response<{}> = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -77,7 +116,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -102,26 +142,10 @@ describe('Home', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchRequests', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [account],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('FollowRequests/fetchRequests')
expect(store.state.FollowRequests.requests).toEqual([account])
})
@@ -136,32 +160,18 @@ describe('Home', () => {
}
})
it('should be succeed', async () => {
- const mockClient = {
- post: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response<{}> = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- },
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getFollowRequests = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('FollowRequests/acceptRequest', account)
expect(store.state.FollowRequests.requests).toEqual([])
})
@@ -176,32 +186,18 @@ describe('Home', () => {
}
})
it('should be succeed', async () => {
- const mockClient = {
- post: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response<{}> = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- },
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getFollowRequests = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('FollowRequests/rejectRequest', account)
expect(store.state.FollowRequests.requests).toEqual([])
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
index 2429deea..b3aa794f 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
@@ -1,13 +1,30 @@
-import { Response, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Tag, { TagState } from '@/store/TimelineSpace/Contents/Hashtag/Tag'
import { LoadPositionWithTag } from '@/types/loadPosition'
-jest.mock('megalodon')
+const mockClient = {
+ getTagTimeline: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,7 +45,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -55,11 +72,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -86,7 +103,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -141,26 +158,10 @@ describe('Home', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetch', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const statuses = await store.dispatch('Tag/fetch', 'tag')
expect(statuses).toEqual([status1])
expect(store.state.Tag.timeline).toEqual([status1])
@@ -181,20 +182,17 @@ describe('Home', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getTagTimeline = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
const loadPositionWithTag: LoadPositionWithTag = {
status: status1,
tag: 'tag'
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
index 342ce756..83e5212a 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Home.spec.ts
@@ -1,12 +1,29 @@
-import { Response, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Home, { HomeState } from '@/store/TimelineSpace/Contents/Home'
-jest.mock('megalodon')
+const mockClient = {
+ getHomeTimeline: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -27,7 +44,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -54,11 +71,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -85,7 +102,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -142,26 +159,10 @@ describe('Home', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchTimeline', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const statuses = await store.dispatch('Home/fetchTimeline')
expect(statuses).toEqual([status1])
expect(store.state.Home.timeline).toEqual([status1])
@@ -184,20 +185,18 @@ describe('Home', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getHomeTimeline = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
+
await store.dispatch('Home/lazyFetchTimeline', status1)
expect(store.state.Home.lazyLoading).toEqual(false)
expect(store.state.Home.timeline).toEqual([status1, status2])
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts
index 4cdc949e..231355ca 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Edit.spec.ts
@@ -1,13 +1,41 @@
-import { Response, Account } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Edit, { EditState } from '@/store/TimelineSpace/Contents/Lists/Edit'
import { RemoveAccountFromList } from '@/types/removeAccountFromList'
-jest.mock('megalodon')
+const mockClient = {
+ getAccountsInList: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [account],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ deleteAccountsFromList: () => {
+ return new Promise>(resolve => {
+ const res: Response<{}> = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -50,7 +78,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -75,26 +104,10 @@ describe('Lists/Edit', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchMembers', () => {
- it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [account],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
+ it('should get', async () => {
await store.dispatch('Edit/fetchMembers', 'id')
expect(store.state.Edit.members).toEqual([account])
})
@@ -102,21 +115,6 @@ describe('Lists/Edit', () => {
describe('removeAccount', () => {
it('should be removed', async () => {
- const mockClient = {
- del: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response<{}> = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const removeFromList: RemoveAccountFromList = {
account: account,
listId: 'id'
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts
index b6e4c499..99182168 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Index.spec.ts
@@ -1,12 +1,40 @@
-import { Response, List } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Index, { IndexState } from '@/store/TimelineSpace/Contents/Lists/Index'
-jest.mock('megalodon')
+const mockClient = {
+ getLists: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [list],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ createList: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: list,
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const list: List = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const list: Entity.List = {
id: '1',
title: 'list1'
}
@@ -32,7 +60,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -57,26 +86,10 @@ describe('Lists/Index', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchLists', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [list],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Index/fetchLists')
expect(store.state.Index.lists).toEqual([list])
})
@@ -84,22 +97,7 @@ describe('Lists/Index', () => {
describe('createList', () => {
it('should be created', async () => {
- const mockClient = {
- post: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: list,
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
- const res: List = await store.dispatch('Index/createList', 'list1')
+ const res: Entity.List = await store.dispatch('Index/createList', 'list1')
expect(res.title).toEqual('list1')
})
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts
index 0591b809..a119e403 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Lists/Show.spec.ts
@@ -1,13 +1,30 @@
-import { Response, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Show, { ShowState } from '@/store/TimelineSpace/Contents/Lists/Show'
import { LoadPositionWithList } from '@/types/loadPosition'
-jest.mock('megalodon')
+const mockClient = {
+ getListTimeline: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -29,7 +46,7 @@ const account: Account = {
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -56,12 +73,12 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -88,7 +105,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -143,26 +160,10 @@ describe('Lists/Show', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchTimeline', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Show/fetchTimeline', '1')
expect(store.state.Show.timeline).toEqual([status1])
})
@@ -181,21 +182,18 @@ describe('Lists/Show', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getListTimeline = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
const loadPosition: LoadPositionWithList = {
status: status1,
list_id: '1'
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts
index 34990cac..9fa4828e 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Local.spec.ts
@@ -1,12 +1,29 @@
-import { Response, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Local, { LocalState } from '@/store/TimelineSpace/Contents/Local'
-jest.mock('megalodon')
+const mockClient = {
+ getLocalTimeline: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -27,7 +44,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -54,11 +71,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -85,7 +102,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -140,26 +157,10 @@ describe('Home', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchLocalTimeline', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const statuses = await store.dispatch('Local/fetchLocalTimeline')
expect(statuses).toEqual([status1])
expect(store.state.Local.timeline).toEqual([status1])
@@ -182,20 +183,18 @@ describe('Home', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getLocalTimeline = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
+
await store.dispatch('Local/lazyFetchTimeline', status1)
expect(store.state.Local.lazyLoading).toEqual(false)
expect(store.state.Local.timeline).toEqual([status1, status2])
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts
index 74372a32..f57afb42 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Mentions.spec.ts
@@ -1,12 +1,29 @@
-import { Response, Account, Notification, Status, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Mentions from '~/src/renderer/store/TimelineSpace/Contents/Mentions'
-jest.mock('megalodon')
+const mockClient = {
+ getNotifications: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [mention, reblog, favourite, follow],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,7 +45,7 @@ const account: Account = {
bot: false
}
-const status: Status = {
+const status: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -55,12 +72,12 @@ const status: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const mention: Notification = {
+const mention: Entity.Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: '1',
@@ -68,7 +85,7 @@ const mention: Notification = {
type: 'mention'
}
-const reblog: Notification = {
+const reblog: Entity.Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: '2',
@@ -76,7 +93,7 @@ const reblog: Notification = {
type: 'reblog'
}
-const favourite: Notification = {
+const favourite: Entity.Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: '3',
@@ -84,11 +101,10 @@ const favourite: Notification = {
type: 'favourite'
}
-const follow: Notification = {
+const follow: Entity.Notification = {
account: account,
created_at: '2019-03-26T21:40:32',
id: '4',
- status: null,
type: 'follow'
}
@@ -142,26 +158,10 @@ describe('Mentions', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchMentions', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: [mention, reblog, favourite, follow],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Mentions/fetchMentions')
expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
})
@@ -199,21 +199,18 @@ describe('Mentions', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: [favourite, follow],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getNotifications = () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [favourite, follow],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Mentions/lazyFetchMentions', { id: 1 })
expect(store.state.Mentions.mentions).toEqual([mention, reblog, favourite, follow])
expect(store.state.Mentions.lazyLoading).toEqual(false)
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
index 062c6a1e..2cfe0eb7 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Notifications.spec.ts
@@ -1,12 +1,29 @@
-import { Response, Status, Account, Application, Notification } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon.ts'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Notifications, { NotificationsState } from '@/store/TimelineSpace/Contents/Notifications'
-jest.mock('megalodon')
+const mockClient = {
+ getNotifications: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [notification1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account1: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account1: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,7 +45,7 @@ const account1: Account = {
bot: false
}
-const account2: Account = {
+const account2: Entity.Account = {
id: '2',
username: 'h3poteto',
acct: 'h3poteto@mstdn.io',
@@ -50,7 +67,7 @@ const account2: Account = {
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -77,12 +94,12 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -109,12 +126,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -141,12 +158,12 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const notification1: Notification = {
+const notification1: Entity.Notification = {
id: '1',
account: account2,
status: status1,
@@ -154,7 +171,7 @@ const notification1: Notification = {
created_at: '2019-04-01T17:01:32'
}
-const notification2: Notification = {
+const notification2: Entity.Notification = {
id: '2',
account: account2,
status: rebloggedStatus,
@@ -212,26 +229,10 @@ describe('Notifications', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchNotifications', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [notification1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const response = await store.dispatch('Notifications/fetchNotifications')
expect(response).toEqual([notification1])
expect(store.state.Notifications.notifications).toEqual([notification1])
@@ -251,20 +252,17 @@ describe('Notifications', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [notification2],
- status: 200,
- statusText: '200',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getNotifications = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [notification2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Notifications/lazyFetchNotifications', notification1)
expect(store.state.Notifications.lazyLoading).toEqual(false)
expect(store.state.Notifications.notifications).toEqual([notification1, notification2])
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts
index b921f269..c108d437 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Public.spec.ts
@@ -1,12 +1,29 @@
-import { Response, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Public, { PublicState } from '@/store/TimelineSpace/Contents/Public'
-jest.mock('megalodon')
+const mockClient = {
+ getPublicTimeline: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status1],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -27,7 +44,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -54,11 +71,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -85,7 +102,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -140,26 +157,10 @@ describe('Home', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchPublicTimeline', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status1],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const statuses = await store.dispatch('Public/fetchPublicTimeline')
expect(statuses).toEqual([status1])
expect(store.state.Public.timeline).toEqual([status1])
@@ -182,20 +183,17 @@ describe('Home', () => {
}
})
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [status2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
+ mockClient.getPublicTimeline = () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [status2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
}
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Public/lazyFetchTimeline', status1)
expect(store.state.Public.lazyLoading).toEqual(false)
expect(store.state.Public.timeline).toEqual([status1, status2])
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts
index 04548b00..a43105bb 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Account.spec.ts
@@ -1,12 +1,9 @@
-import { Response, Account } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import AccountStore, { AccountState } from '@/store/TimelineSpace/Contents/Search/Account'
-jest.mock('megalodon')
-
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,6 +25,26 @@ const account: Account = {
bot: false
}
+const mockClient = {
+ searchAccount: () => {
+ return new Promise>>(resolve => {
+ const res: Response> = {
+ data: [account],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
+
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
let state = (): AccountState => {
return {
results: []
@@ -61,7 +78,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -86,26 +104,10 @@ describe('Search/Account', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('search', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>>(resolve => {
- const res: Response> = {
- data: [account],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Account/search', 'query')
expect(store.state.Account.results).toEqual([account])
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts
index 7548daaa..1af5f607 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Tag.spec.ts
@@ -1,17 +1,38 @@
-import { Response, Results, Tag } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import TagStore, { TagState } from '@/store/TimelineSpace/Contents/Search/Tag'
-jest.mock('megalodon')
-
-const tag1: Tag = {
+const tag1: Entity.Tag = {
name: 'tag1',
url: 'http://example.com/tag1',
history: null
}
+const mockClient = {
+ search: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: {
+ accounts: [],
+ statuses: [],
+ hashtags: [tag1]
+ },
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
+
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
let state = (): TagState => {
return {
results: []
@@ -45,7 +66,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
const appState = {
@@ -55,7 +77,7 @@ const appState = {
}
}
-describe('Search/Account', () => {
+describe('Search/Tag', () => {
let store
let localVue
@@ -69,30 +91,10 @@ describe('Search/Account', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('search', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: {
- accounts: [],
- statuses: [],
- hashtags: [tag1]
- },
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Tag/search', 'query')
expect(store.state.Tag.results).toEqual([tag1])
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts
index 50cb8a1e..65b966a1 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/Search/Toots.spec.ts
@@ -1,12 +1,33 @@
-import { Response, Results, Status, Account, Application } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import Toots, { TootsState } from '@/store/TimelineSpace/Contents/Search/Toots'
-jest.mock('megalodon')
+const mockClient = {
+ search: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: {
+ accounts: [],
+ statuses: [status],
+ hashtags: []
+ },
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,7 +49,7 @@ const account: Account = {
bot: false
}
-const status: Status = {
+const status: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -55,7 +76,7 @@ const status: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -93,7 +114,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -118,30 +140,10 @@ describe('Search/Account', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('search', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: {
- accounts: [],
- statuses: [status],
- hashtags: []
- },
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('Toots/search', 'query')
expect(store.state.Toots.results).toEqual([status])
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts
index 78996218..826c29c9 100644
--- a/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Contents/SideBar/AccountProfile.spec.ts
@@ -1,9 +1,9 @@
-import { Account } from 'megalodon'
+import { Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import AccountProfile, { AccountProfileState } from '~/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile'
-const state = (account: Account | null): AccountProfileState => {
+const state = (account: Entity.Account | null): AccountProfileState => {
return {
loading: false,
relationship: null,
@@ -29,7 +29,7 @@ const timelineSpace = {
}
}
-const initStore = (account: Account | null) => {
+const initStore = (account: Entity.Account | null) => {
return {
namespaced: true,
state: state(account),
@@ -56,7 +56,7 @@ describe('AccountProfile', () => {
describe('isOwnProfile', () => {
describe('target is a same Mastodon account', () => {
- const account: Account = {
+ const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@example.com',
@@ -91,7 +91,7 @@ describe('AccountProfile', () => {
})
describe('target is another Mastodon account', () => {
- const account: Account = {
+ const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@another.example.com',
@@ -126,7 +126,7 @@ describe('AccountProfile', () => {
})
describe('target is a same Pleroma account', () => {
- const account: Account = {
+ const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@example.com',
@@ -161,7 +161,7 @@ describe('AccountProfile', () => {
})
describe('target is another Pleroma account', () => {
- const account: Account = {
+ const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@another.example.com',
diff --git a/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts b/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts
index 83ae79a4..95caf008 100644
--- a/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/HeaderMenu.spec.ts
@@ -1,16 +1,33 @@
-import { Response, List } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import HeaderMenu, { HeaderMenuState } from '~/src/renderer/store/TimelineSpace/HeaderMenu'
-jest.mock('megalodon')
-
-const list: List = {
+const list: Entity.List = {
id: '1',
title: 'example'
}
+const mockClient = {
+ getList: (_listID: string) => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: list,
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
+
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
const state = (): HeaderMenuState => {
return {
title: 'Home',
@@ -34,7 +51,8 @@ const timelineState = {
account: {
accessToken: 'token',
baseURL: 'http://localhost'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -59,26 +77,10 @@ describe('HeaderMenu', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('fetchLists', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: list,
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const l = await store.dispatch('HeaderMenu/fetchList', list.id)
expect(l).toEqual(list)
expect(store.state.HeaderMenu.title).toEqual(`#${list.title}`)
diff --git a/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts b/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts
index aa0ddfd7..977f6962 100644
--- a/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Modals/AddListMember.spec.ts
@@ -1,12 +1,40 @@
-import { Response, Account } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import AddListMember, { AddListMemberState } from '@/store/TimelineSpace/Modals/AddListMember'
-jest.mock('megalodon')
+const mockClient = {
+ searchAccount: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [account],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ addAccountsToList: () => {
+ return new Promise(resolve => {
+ const res: Response = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -50,7 +78,8 @@ const timelineState = {
state: {
account: {
_id: '0'
- }
+ },
+ sns: 'mastodon'
}
}
@@ -75,7 +104,6 @@ describe('AddListMember', () => {
App: appState
}
})
- mockedMegalodon.mockClear()
})
describe('changeModal', () => {
@@ -87,21 +115,6 @@ describe('AddListMember', () => {
describe('search', () => {
it('should be searched', async () => {
- const mockClient = {
- get: () => {
- return new Promise>(resolve => {
- const res: Response = {
- data: [account],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('AddListMember/search', 'akira')
expect(store.state.AddListMember.accounts).toEqual([account])
})
@@ -109,21 +122,6 @@ describe('AddListMember', () => {
describe('add', () => {
it('should be added a member to the list', async () => {
- const mockClient = {
- post: () => {
- return new Promise(resolve => {
- const res: Response = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
const result = await store.dispatch('AddListMember/add', 'akira')
expect(result).toEqual({})
})
diff --git a/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts b/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts
index bdcfdfed..a7ef09f6 100644
--- a/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/Modals/ListMembership.spec.ts
@@ -1,12 +1,62 @@
-import { Response, List, Account } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Response, Entity } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import ListMembership, { ListMembershipState } from '@/store/TimelineSpace/Modals/ListMembership'
-jest.mock('megalodon')
+const mockClient = {
+ getAccountLists: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [list1, list2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ getLists: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [list1, list2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ deleteAccountsFromList: () => {
+ return new Promise(resolve => {
+ const res: Response = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ },
+ addAccountsToList: () => {
+ return new Promise(resolve => {
+ const res: Response = {
+ data: {},
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const account: Account = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -28,12 +78,12 @@ const account: Account = {
bot: false
}
-const list1: List = {
+const list1: Entity.List = {
id: '1',
title: 'list1'
}
-const list2: List = {
+const list2: Entity.List = {
id: '2',
title: 'list2'
}
@@ -89,21 +139,7 @@ describe('ListMembership', () => {
})
describe('fetchListMembership', () => {
- it('should be changed', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: [list1, list2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
- mockedMegalodon.mockImplementation(() => mockClient)
+ it('should get', async () => {
await store.dispatch('ListMembership/fetchListMembership', {
id: '5'
})
@@ -113,20 +149,6 @@ describe('ListMembership', () => {
describe('fetchLists', () => {
it('should be changed', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: [list1, list2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('ListMembership/fetchLists')
expect(store.state.ListMembership.lists).toEqual([list1, list2])
})
@@ -144,31 +166,6 @@ describe('ListMembership', () => {
}
})
it('should be changed', async () => {
- const mockClient = {
- del: (_path: string, _params: object) => {
- return new Promise(resolve => {
- const res: Response = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- },
- post: (_path: string, _params: object) => {
- return new Promise(resolve => {
- const res: Response = {
- data: {},
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
- mockedMegalodon.mockImplementation(() => mockClient)
await store.dispatch('ListMembership/changeBelongToLists', [list1])
expect(store.state.ListMembership.belongToLists).toEqual([list1])
})
diff --git a/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts b/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts
index dda5ad33..2e355665 100644
--- a/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts
@@ -1,5 +1,4 @@
-import { Response, List } from 'megalodon'
-import mockedMegalodon from '~/spec/mock/megalodon'
+import { Entity, Response } from 'megalodon'
import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import { ipcMain, ipcRenderer } from '~/spec/mock/electron'
@@ -8,14 +7,34 @@ import { LocalTag } from '~/src/types/localTag'
import { MyWindow } from '~/src/types/global'
;(window as MyWindow).ipcRenderer = ipcRenderer
-jest.mock('megalodon')
+const mockClient = {
+ getLists: () => {
+ return new Promise>(resolve => {
+ const res: Response = {
+ data: [list1, list2],
+ status: 200,
+ statusText: 'OK',
+ headers: {}
+ }
+ resolve(res)
+ })
+ }
+}
-const list1: List = {
+jest.mock('megalodon', () => ({
+ ...jest.requireActual('megalodon'),
+ default: jest.fn(() => mockClient),
+ __esModule: true
+}))
+
+// import mockedMegalodon from '~/spec/mock/megalodon'
+
+const list1: Entity.List = {
id: '1',
title: 'example1'
}
-const list2: List = {
+const list2: Entity.List = {
id: '2',
title: 'example2'
}
@@ -44,13 +63,20 @@ const initStore = () => {
}
}
-const appState = {
+const appStore = {
namespaced: true,
state: {
proxyConfiguration: false
}
}
+const timelineStore = {
+ namespaced: true,
+ state: {
+ sns: 'mastodon'
+ }
+}
+
describe('SideMenu', () => {
let store
let localVue
@@ -61,29 +87,16 @@ describe('SideMenu', () => {
store = new Vuex.Store({
modules: {
SideMenu: initStore(),
- App: appState
+ App: appStore,
+ TimelineSpace: timelineStore
}
})
- mockedMegalodon.mockClear()
+ // mockedMegalodon.mockClear()
})
describe('fetchLists', () => {
it('should be updated', async () => {
- const mockClient = {
- get: (_path: string, _params: object) => {
- return new Promise>(resolve => {
- const res: Response = {
- data: [list1, list2],
- status: 200,
- statusText: 'OK',
- headers: {}
- }
- resolve(res)
- })
- }
- }
-
- mockedMegalodon.mockImplementation(() => mockClient)
+ // mockedMegalodon.mockImplementation(() => mockClient)
const account = {
accessToken: 'token',
baseURL: 'http://localhost'
diff --git a/spec/renderer/unit/store/TimelineSpace.spec.ts b/spec/renderer/unit/store/TimelineSpace.spec.ts
index 6c0af57f..c8bcad0f 100644
--- a/spec/renderer/unit/store/TimelineSpace.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace.spec.ts
@@ -16,7 +16,7 @@ describe('TimelineSpace', () => {
local: unreadSettings.Local.default,
public: unreadSettings.Public.default
},
- pleroma: false
+ sns: 'mastodon'
}
})
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
index fa0c5249..2db3c39e 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/DirectMessages.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import DirectMessages, { DirectMessagesState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/DirectMessages'
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -22,7 +22,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -49,11 +49,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -80,12 +80,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -112,7 +112,7 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
index e05edaed..6f860717 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Hashtag/Tag.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Tag, { TagState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Hashtag/Tag'
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -22,7 +22,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -49,11 +49,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -80,12 +80,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -112,7 +112,7 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
index 800c9ec4..48cc8b82 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Home.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Home, { HomeState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Home'
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -22,7 +22,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -49,11 +49,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -80,7 +80,7 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
@@ -245,7 +245,7 @@ describe('TimelineSpace/Contents/Home', () => {
showReplies: true
}
})
- const favouritedStatus: Status = Object.assign(status1, {
+ const favouritedStatus: Entity.Status = Object.assign(status1, {
favourited: true
})
it('should be updated', () => {
@@ -254,7 +254,7 @@ describe('TimelineSpace/Contents/Home', () => {
})
})
describe('message is reblogged', () => {
- const rebloggedStatus: Status = {
+ const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -281,11 +281,11 @@ describe('TimelineSpace/Contents/Home', () => {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
- const favouritedStatus: Status = Object.assign(status1, {
+ const favouritedStatus: Entity.Status = Object.assign(status1, {
favourited: true
})
beforeEach(() => {
@@ -328,7 +328,7 @@ describe('TimelineSpace/Contents/Home', () => {
describe('message is reblogged', () => {
beforeEach(() => {
- const rebloggedStatus: Status = {
+ const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -355,7 +355,7 @@ describe('TimelineSpace/Contents/Home', () => {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
index bae785cb..971f0e78 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Lists/Show.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Show, { ShowState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Lists/Show'
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -22,7 +22,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -49,11 +49,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -80,12 +80,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -112,7 +112,7 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
index 899eb185..33c3a292 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Local.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Local, { LocalState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Local'
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -22,7 +22,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -49,11 +49,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -80,12 +80,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -112,7 +112,7 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
index eff364f1..9497f4d7 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Mentions.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Notification, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Mentions, { MentionsState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Mentions'
-const account1: Account = {
+const account1: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -23,7 +23,7 @@ const account1: Account = {
bot: false
}
-const account2: Account = {
+const account2: Entity.Account = {
id: '2',
username: 'h3poteto',
acct: 'h3poteto@mstdn.io',
@@ -45,7 +45,7 @@ const account2: Account = {
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -72,12 +72,12 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -104,12 +104,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -136,12 +136,12 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const notification1: Notification = {
+const notification1: Entity.Notification = {
id: '1',
account: account2,
status: status1,
@@ -149,7 +149,7 @@ const notification1: Notification = {
created_at: '2019-04-01T17:01:32'
}
-const notification2: Notification = {
+const notification2: Entity.Notification = {
id: '2',
account: account2,
status: rebloggedStatus,
@@ -288,7 +288,7 @@ describe('TimelineSpace/Contents/Mentions', () => {
}
})
it('should be updated', () => {
- const favourited: Status = Object.assign(status1, {
+ const favourited: Entity.Status = Object.assign(status1, {
favourited: true
})
Mentions.mutations![MUTATION_TYPES.UPDATE_TOOT](state, favourited)
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
index 99f54e36..adaea4d0 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Notifications.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Notification, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Notifications, { NotificationsState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Notifications'
-const account1: Account = {
+const account1: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -23,7 +23,7 @@ const account1: Account = {
bot: false
}
-const account2: Account = {
+const account2: Entity.Account = {
id: '2',
username: 'h3poteto',
acct: 'h3poteto@mstdn.io',
@@ -45,7 +45,7 @@ const account2: Account = {
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -72,12 +72,12 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -104,12 +104,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -136,12 +136,12 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const notification1: Notification = {
+const notification1: Entity.Notification = {
id: '1',
account: account2,
status: status1,
@@ -149,7 +149,7 @@ const notification1: Notification = {
created_at: '2019-04-01T17:01:32'
}
-const notification2: Notification = {
+const notification2: Entity.Notification = {
id: '2',
account: account2,
status: rebloggedStatus,
diff --git a/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts b/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
index 183cbb4e..a77487e3 100644
--- a/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Contents/Public.spec.ts
@@ -1,7 +1,7 @@
-import { Account, Status, Application } from 'megalodon'
+import { Entity } from 'megalodon'
import Public, { PublicState, MUTATION_TYPES } from '@/store/TimelineSpace/Contents/Public'
-const account: Account = {
+const account: Entity.Account = {
id: '1',
username: 'h3poteto',
acct: 'h3poteto@pleroma.io',
@@ -22,7 +22,7 @@ const account: Account = {
fields: null,
bot: false
}
-const status1: Status = {
+const status1: Entity.Status = {
id: '1',
uri: 'http://example.com',
url: 'http://example.com',
@@ -49,11 +49,11 @@ const status1: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const status2: Status = {
+const status2: Entity.Status = {
id: '2',
uri: 'http://example.com',
url: 'http://example.com',
@@ -80,12 +80,12 @@ const status2: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
-const rebloggedStatus: Status = {
+const rebloggedStatus: Entity.Status = {
id: '3',
uri: 'http://example.com',
url: 'http://example.com',
@@ -112,7 +112,7 @@ const rebloggedStatus: Status = {
poll: null,
application: {
name: 'Web'
- } as Application,
+ } as Entity.Application,
language: null,
pinned: null
}
diff --git a/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts b/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts
index b594a5a5..48e436ef 100644
--- a/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts
@@ -1,7 +1,7 @@
import i18n from '~/src/config/i18n'
import Jump, { JumpState, MUTATION_TYPES, Channel } from '@/store/TimelineSpace/Modals/Jump'
import { LocalTag } from '~/src/types/localTag'
-import { List } from 'megalodon'
+import { Entity } from 'megalodon'
describe('TimelineSpace/Modals/Jump', () => {
describe('mutations', () => {
@@ -55,15 +55,15 @@ describe('TimelineSpace/Modals/Jump', () => {
describe('updateListChannel', () => {
it('should be updated', () => {
- const admin: List = {
+ const admin: Entity.List = {
id: '0',
title: 'admin'
}
- const engineer: List = {
+ const engineer: Entity.List = {
id: '1',
title: 'engineer'
}
- const designer: List = {
+ const designer: Entity.List = {
id: '2',
title: 'designer'
}