-
Notifications
You must be signed in to change notification settings - Fork 0
/
segment-text.test.js
92 lines (91 loc) · 1.62 KB
/
segment-text.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { expect, it } from 'vitest'
import { segmentText } from './segment-text.js'
it('segmentText', () => {
let text = `
https://mp.weixin.qq.com/s/jLMBp1e7BC-PGr2tLEQpRQ
周日读报[愉快]
新数字经济协定[强]
毕业生就业压力[白眼]
鼓励生育政策多[玫瑰]
居民用电高档贵[悠闲]
煤炭产量有保障[Rich]
汽车消费发补贴[色]
foo bar
[]
[404]
`.trim()
expect(segmentText(text)).toMatchInlineSnapshot(`
[
{
"text": "https://mp.weixin.qq.com/s/jLMBp1e7BC-PGr2tLEQpRQ
周日读报",
"type": "text",
},
{
"index": 21,
"type": "qqface",
},
{
"text": "
新数字经济协定",
"type": "text",
},
{
"index": 79,
"type": "qqface",
},
{
"text": "
毕业生就业压力",
"type": "text",
},
{
"index": 22,
"type": "qqface",
},
{
"text": "
鼓励生育政策多",
"type": "text",
},
{
"index": 63,
"type": "qqface",
},
{
"text": "
居民用电高档贵",
"type": "text",
},
{
"index": 29,
"type": "qqface",
},
{
"text": "
煤炭产量有保障",
"type": "text",
},
{
"index": 108,
"type": "qqface",
},
{
"text": "
汽车消费发补贴",
"type": "text",
},
{
"index": 2,
"type": "qqface",
},
{
"text": "
foo bar
[]
[404]",
"type": "text",
},
]
`)
})