mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-25 18:03:40 +00:00
test(api): add tests for br
p
a
elements
This commit is contained in:
parent
cc1db1613a
commit
cb8d727e7a
@ -1,5 +1,120 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Red 编码器应当正确编码 br 换行 1`] = `
|
||||
[
|
||||
[
|
||||
{
|
||||
"chatType": 2,
|
||||
"guildId": "",
|
||||
"peerUid": "9998",
|
||||
},
|
||||
[
|
||||
{
|
||||
"elementId": "",
|
||||
"elementType": 1,
|
||||
"textElement": {
|
||||
"atNtUid": "",
|
||||
"atTinyId": "",
|
||||
"atType": 0,
|
||||
"atUid": "",
|
||||
"content": "
|
||||
aaa
|
||||
bbb
|
||||
|
||||
ccc
|
||||
|
||||
|
||||
ddd",
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Red 编码器应当正确编码 br/p 混搭换行 1`] = `
|
||||
[
|
||||
[
|
||||
{
|
||||
"chatType": 2,
|
||||
"guildId": "",
|
||||
"peerUid": "9998",
|
||||
},
|
||||
[
|
||||
{
|
||||
"elementId": "",
|
||||
"elementType": 1,
|
||||
"textElement": {
|
||||
"atNtUid": "",
|
||||
"atTinyId": "",
|
||||
"atType": 0,
|
||||
"atUid": "",
|
||||
"content": "aaa
|
||||
bbb
|
||||
uuu
|
||||
|
||||
ccc
|
||||
ddd
|
||||
|
||||
eee
|
||||
|
||||
vvv
|
||||
www
|
||||
fff
|
||||
ggg
|
||||
|
||||
hhh
|
||||
iii
|
||||
|
||||
xxx
|
||||
yyy
|
||||
|
||||
|
||||
zzz",
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Red 编码器应当正确编码 p 换行 1`] = `
|
||||
[
|
||||
[
|
||||
{
|
||||
"chatType": 2,
|
||||
"guildId": "",
|
||||
"peerUid": "9998",
|
||||
},
|
||||
[
|
||||
{
|
||||
"elementId": "",
|
||||
"elementType": 1,
|
||||
"textElement": {
|
||||
"atNtUid": "",
|
||||
"atTinyId": "",
|
||||
"atType": 0,
|
||||
"atUid": "",
|
||||
"content": "aaa
|
||||
bbb
|
||||
|
||||
ccc
|
||||
ddd
|
||||
|
||||
eee
|
||||
|
||||
fff
|
||||
ggg
|
||||
|
||||
hhh
|
||||
iii",
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Red 编码器应当正确编码 纯文本消息 1`] = `
|
||||
[
|
||||
[
|
||||
@ -24,3 +139,28 @@ exports[`Red 编码器应当正确编码 纯文本消息 1`] = `
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`Red 编码器应当正确编码 链接 1`] = `
|
||||
[
|
||||
[
|
||||
{
|
||||
"chatType": 2,
|
||||
"guildId": "",
|
||||
"peerUid": "9998",
|
||||
},
|
||||
[
|
||||
{
|
||||
"elementId": "",
|
||||
"elementType": 1,
|
||||
"textElement": {
|
||||
"atNtUid": "",
|
||||
"atTinyId": "",
|
||||
"atType": 0,
|
||||
"atUid": "",
|
||||
"content": "Chronocat ( https://chronocat.vercel.app )",
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
@ -25,3 +25,103 @@ test('Red 编码器应当正确编码 纯文本消息', async () => {
|
||||
|
||||
expect(sendCalls).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Red 编码器应当正确编码 链接', async () => {
|
||||
const commonSend = jest.fn(async () => undefined as unknown as RedMessage)
|
||||
const commonSave = jest.fn(async () => saveResult)
|
||||
const commonSendForward = jest.fn(
|
||||
async () => undefined as unknown as RedMessage,
|
||||
)
|
||||
|
||||
await new Messager(
|
||||
ctx,
|
||||
satoriConfig,
|
||||
{
|
||||
send: commonSend,
|
||||
save: commonSave,
|
||||
sendForward: commonSendForward,
|
||||
},
|
||||
'9998',
|
||||
).send(h.parse('<a href="https://chronocat.vercel.app">Chronocat</a>'))
|
||||
|
||||
const sendCalls = commonSend.mock.calls.map((x) => x.slice(1))
|
||||
|
||||
expect(sendCalls).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Red 编码器应当正确编码 br 换行', async () => {
|
||||
const commonSend = jest.fn(async () => undefined as unknown as RedMessage)
|
||||
const commonSave = jest.fn(async () => saveResult)
|
||||
const commonSendForward = jest.fn(
|
||||
async () => undefined as unknown as RedMessage,
|
||||
)
|
||||
|
||||
await new Messager(
|
||||
ctx,
|
||||
satoriConfig,
|
||||
{
|
||||
send: commonSend,
|
||||
save: commonSave,
|
||||
sendForward: commonSendForward,
|
||||
},
|
||||
'9998',
|
||||
).send(h.parse('<br/>aaa<br/>bbb<br/><br/>ccc<br/><br/><br/>ddd<br/>'))
|
||||
|
||||
const sendCalls = commonSend.mock.calls.map((x) => x.slice(1))
|
||||
|
||||
expect(sendCalls).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Red 编码器应当正确编码 p 换行', async () => {
|
||||
const commonSend = jest.fn(async () => undefined as unknown as RedMessage)
|
||||
const commonSave = jest.fn(async () => saveResult)
|
||||
const commonSendForward = jest.fn(
|
||||
async () => undefined as unknown as RedMessage,
|
||||
)
|
||||
|
||||
await new Messager(
|
||||
ctx,
|
||||
satoriConfig,
|
||||
{
|
||||
send: commonSend,
|
||||
save: commonSave,
|
||||
sendForward: commonSendForward,
|
||||
},
|
||||
'9998',
|
||||
).send(
|
||||
h.parse(
|
||||
'<p></p>aaa<p>bbb</p>ccc<p>ddd</p><p>eee</p><p></p><p></p>fff<p></p><p></p><p>ggg</p><p><p></p></p>hhh<p><p></p></p><p>iii</p><p></p>',
|
||||
),
|
||||
)
|
||||
|
||||
const sendCalls = commonSend.mock.calls.map((x) => x.slice(1))
|
||||
|
||||
expect(sendCalls).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('Red 编码器应当正确编码 br/p 混搭换行', async () => {
|
||||
const commonSend = jest.fn(async () => undefined as unknown as RedMessage)
|
||||
const commonSave = jest.fn(async () => saveResult)
|
||||
const commonSendForward = jest.fn(
|
||||
async () => undefined as unknown as RedMessage,
|
||||
)
|
||||
|
||||
await new Messager(
|
||||
ctx,
|
||||
satoriConfig,
|
||||
{
|
||||
send: commonSend,
|
||||
save: commonSave,
|
||||
sendForward: commonSendForward,
|
||||
},
|
||||
'9998',
|
||||
).send(
|
||||
h.parse(
|
||||
'<p></p>aaa<p>bbb<br/>uuu<br/></p>ccc<p>ddd</p><p>eee</p>vvv<br/>www<p></p><p></p>fff<p></p><p></p><p>ggg</p><p><p></p></p>hhh<p><p></p></p><p>iii</p><p>xxx<br/>yyy</p><p><br/>zzz<br/></p><p></p>',
|
||||
),
|
||||
)
|
||||
|
||||
const sendCalls = commonSend.mock.calls.map((x) => x.slice(1))
|
||||
|
||||
expect(sendCalls).toMatchSnapshot()
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user