-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.spec.ts
57 lines (56 loc) · 1.5 KB
/
index.spec.ts
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
import {createMapMdToEmoji, createRegExpText, emojiMd, textEmoji} from './markdown-to-text'
import emoji from './emoji'
describe('emoji', () => {
it('emoji', () => {
expect(emoji).not.toHaveProperty(':smile:')
expect(emoji).toHaveProperty('smile')
expect(emoji).toHaveProperty('smiling_imp')
})
it('createMapMdToEmoji', () => {
const before = 'x'
const after = ':x:'
expect(createMapMdToEmoji({[before]: true})).toHaveProperty(after)
})
it('emojiMd', () => {
expect(emojiMd).toHaveProperty(':smile:')
expect(emojiMd).not.toHaveProperty('smile')
})
it('createRegExpTest', () => {
const source = {100: true, god: 'wow', '!': 'wow'}
expect(createRegExpText(source)).toEqual(`:(${Object.keys(source).join('|')}):`)
})
it('textEmoji', () => {
[
{
before: `hello i'm :smile: feeling :smiling_imp::smile:`,
after : `hello i'm 😄 feeling 😈😄`
},
{
before: `hello i'm :smile: feeling :smiling_imp::smile:
hello i'm :smile: feeling :smiling_imp::smile:`,
after : `hello i'm 😄 feeling 😈😄
hello i'm 😄 feeling 😈😄`
},
{
before: '',
after : ''
},
{
before: null,
after : ''
},
{
before: 4,
after : '4'
},
{
before: true,
after : 'true'
},
{
before: false,
after : 'false'
}
].map(({before, after}) => expect(textEmoji(before)).toEqual(after))
})
})