upd: megalodon to v7

This commit is contained in:
Mar0xy 2023-09-24 01:44:53 +02:00
parent b4674ce65c
commit afda15260f
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
234 changed files with 21334 additions and 7675 deletions

View file

@ -2,7 +2,7 @@ import MisskeyEntity from '@/misskey/entity'
import MisskeyNotificationType from '@/misskey/notification'
import Misskey from '@/misskey'
import MegalodonNotificationType from '@/notification'
import axios, { AxiosResponse } from 'axios'
import axios, { AxiosHeaders, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
jest.mock('axios')
@ -27,6 +27,7 @@ const note: MisskeyEntity.Note = {
renoteCount: 0,
repliesCount: 0,
reactions: {},
reactionEmojis: {},
emojis: [],
fileIds: [],
files: [],
@ -93,7 +94,7 @@ const pollVote: MisskeyEntity.Notification = {
createdAt: '2021-02-01T01:49:29',
userId: user.id,
user: user,
type: MisskeyNotificationType.PollEnded,
type: MisskeyNotificationType.PollVote,
note: note
}
@ -163,12 +164,12 @@ describe('getNotifications', () => {
},
{
event: reaction,
expected: MegalodonNotificationType.Reaction,
expected: MegalodonNotificationType.EmojiReaction,
title: 'reaction'
},
{
event: pollVote,
expected: MegalodonNotificationType.Poll,
expected: MegalodonNotificationType.PollVote,
title: 'pollVote'
},
{
@ -180,25 +181,38 @@ describe('getNotifications', () => {
event: followRequestAccepted,
expected: MegalodonNotificationType.Follow,
title: 'followRequestAccepted'
},
{
event: groupInvited,
expected: MisskeyNotificationType.GroupInvited,
title: 'groupInvited'
}
]
cases.forEach(c => {
it(`should be ${c.title} event`, async () => {
const config: InternalAxiosRequestConfig<any> = {
headers: new AxiosHeaders()
}
const mockResponse: AxiosResponse<Array<MisskeyEntity.Notification>> = {
data: [c.event],
status: 200,
statusText: '200OK',
headers: {},
config: {}
config: config
}
;(axios.post as any).mockResolvedValue(mockResponse)
const res = await client.getNotifications()
expect(res.data[0].type).toEqual(c.expected)
})
})
it('groupInvited event should be ignored', async () => {
const config: InternalAxiosRequestConfig<any> = {
headers: new AxiosHeaders()
}
const mockResponse: AxiosResponse<Array<MisskeyEntity.Notification>> = {
data: [groupInvited],
status: 200,
statusText: '200OK',
headers: {},
config: config
}
;(axios.post as any).mockResolvedValue(mockResponse)
const res = await client.getNotifications()
expect(res.data).toEqual([])
})
})