forked from gregberge/svgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
68 lines (64 loc) · 2.22 KB
/
index.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
import convert, {
rawConvert,
jsx,
stripAttribute,
expandProps,
replaceAttrValue,
wrapIntoComponent,
} from './'
describe('rawConvert', () => {
it('should convert using specific options', async () => {
const result = await rawConvert(
`
<?xml version="1.0" encoding="UTF-8"?>
<svg width="88px" height="88px" viewBox="0 0 88 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
<title>Dismiss</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Blocks" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="square">
<g id="Dismiss" stroke="#063855" stroke-width="2">
<path d="M51,37 L37,51" id="Shape"></path>
<path d="M51,51 L37,37" id="Shape"></path>
</g>
</g>
</svg>
`,
{
h2x: {
plugins: [
jsx,
stripAttribute('xmlns'),
expandProps,
replaceAttrValue('#063855', 'currentColor'),
],
},
template: wrapIntoComponent({ expandProps: true }),
},
{ filePath: 'MyComponent.js' },
)
expect(result).toMatchSnapshot()
})
})
describe('convert', () => {
it('should convert using config', async () => {
const result = await convert(
`
<?xml version="1.0" encoding="UTF-8"?>
<svg width="88px" height="88px" viewBox="0 0 88 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
<title>Dismiss</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Blocks" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="square">
<g id="Dismiss" stroke="#063855" stroke-width="2">
<path d="M51,37 L37,51" id="Shape"></path>
<path d="M51,51 L37,37" id="Shape"></path>
</g>
</g>
</svg>
`,
)
expect(result).toMatchSnapshot()
})
})