/
snippet.test.ts
60 lines (56 loc) · 1.23 KB
/
snippet.test.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
58
59
60
import { dedent } from 'node/markdown/plugins/snippet'
describe('node/markdown/plugins/snippet', () => {
describe('dedent', () => {
test('when 0-level is minimal, do not remove spaces', () => {
expect(
dedent(
[
//
'fn main() {',
' println!("Hello");',
'}'
].join('\n')
)
).toMatchInlineSnapshot(`
"fn main() {
println!(\\"Hello\\");
}"
`)
})
test('when 4-level is minimal, remove 4 spaces', () => {
expect(
dedent(
[
//
' let a = {',
' value: 42',
' };'
].join('\n')
)
).toMatchInlineSnapshot(`
"let a = {
value: 42
};"
`)
})
test('when only 1 line is passed, dedent it', () => {
expect(dedent(' let a = 42;')).toEqual('let a = 42;')
})
test('handle tabs as well', () => {
expect(
dedent(
[
//
' let a = {',
' value: 42',
' };'
].join('\n')
)
).toMatchInlineSnapshot(`
"let a = {
value: 42
};"
`)
})
})
})