forked from imagemin/imagemin-svgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
30 lines (24 loc) · 804 Bytes
/
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
import test from 'ava';
import imageminSvgo from './index.js';
test('optimize a SVG', async t => {
const buffer = await imageminSvgo()('<svg><script></script></svg>');
t.is(buffer.toString(), '<svg><script/></svg>');
});
test('support SVGO options', async t => {
const buffer = await imageminSvgo({
plugins: [{
name: 'preset-default',
}, {
name: 'removeScriptElement',
active: true,
}],
})('<svg><script></script></svg>');
t.is(buffer.toString(), '<svg/>');
});
// Failing as SVGO doesn't throw proper errors...
test.failing('error on corrupt SVG', async t => {
await t.throwsAsync(imageminSvgo()('<svg>style><</style></svg>'), {message: /Error in parsing SVG/});
});
test('ignore non valid SVG', async t => {
t.is(await imageminSvgo()('<html></html>'), '<html></html>');
});