|
1 | | -import test from "ava"; |
2 | | -import path from "path"; |
3 | | -const fs = require("fs"); |
4 | | -const outlineStroke = require("./"); |
| 1 | +import test from 'ava' |
| 2 | +const fs = require('fs') |
| 3 | +const outlineStroke = require('./') |
5 | 4 |
|
6 | 5 | const src = ` |
7 | | -<svg xmlns="http://www.w3.org/2000/svg" width="506.3" height="506.3" viewBox="0 0 506.3 506.3"><g fill="none" stroke="#202020" stroke-width="16.333" stroke-miterlimit="10"><path d="M122.5 122.5h375.7v375.7H122.5z"/><path d="M122.5 383.8H8.2V8.2h375.6v114.3M310.3 204.2v212.3M416.5 310.3H204.2"/></g></svg>`; |
| 6 | +<svg xmlns="http://www.w3.org/2000/svg" width="506.3" height="506.3" viewBox="0 0 506.3 506.3"><g fill="none" stroke="#202020" stroke-width="16.333" stroke-miterlimit="10"><path d="M122.5 122.5h375.7v375.7H122.5z"/><path d="M122.5 383.8H8.2V8.2h375.6v114.3M310.3 204.2v212.3M416.5 310.3H204.2"/></g></svg>` |
8 | 7 |
|
9 | 8 | const expected = `<svg xmlns="http://www.w3.org/2000/svg" width="506" height="506" viewBox="0 0 506 506" version="1.1"> |
10 | 9 | <path d="M 0 196 L 0 392 57 392 L 114 392 114 449 L 114 506 309.835 506 L 505.671 506 506.335 419.750 C 506.700 372.313, 506.890 258.350, 506.758 166.500 C 506.625 74.650, 506.397 25.263, 506.250 56.750 L 505.984 114 448.992 114 L 392 114 392 57 L 392 0 196 0 L 0 0 0 196 M 0.490 196.500 C 0.490 304.300, 0.607 348.252, 0.750 294.170 C 0.893 240.089, 0.893 151.889, 0.750 98.170 C 0.607 44.452, 0.490 88.700, 0.490 196.500 M 16.667 16.667 C 16.300 17.033, 16 97.808, 16 196.167 L 16 375 65 375 L 114 375 114 244.500 L 114 114 244.500 114 L 375 114 375 65 L 375 16 196.167 16 C 97.808 16, 17.033 16.300, 16.667 16.667 M 131 310.500 L 131 490 310.500 490 L 490 490 490 310.500 L 490 131 310.500 131 L 131 131 131 310.500 M 302 253 L 302 302 253 302 L 204 302 204 310 L 204 318 253 318 L 302 318 302 367 L 302 416 310 416 L 318 416 318 367 L 318 318 367 318 L 416 318 416 310 L 416 302 367 302 L 318 302 318 253 L 318 204 310 204 L 302 204 302 253" stroke="none" fill="black" fill-rule="evenodd"/> |
11 | | -</svg>`; |
| 10 | +</svg>` |
12 | 11 |
|
13 | 12 | const expectedWithParams = `<svg xmlns="http://www.w3.org/2000/svg" width="506" height="506" viewBox="0 0 506 506" version="1.1"> |
14 | 13 | <rect x="0" y="0" width="100%" height="100%" fill="#a1a5a5" /> |
15 | 14 | <path d="M 0 196 L 0 392 57 392 L 114 392 114 449 L 114 506 309.835 506 L 505.671 506 506.335 419.750 C 506.700 372.313, 506.890 258.350, 506.758 166.500 C 506.625 74.650, 506.397 25.263, 506.250 56.750 L 505.984 114 448.992 114 L 392 114 392 57 L 392 0 196 0 L 0 0 0 196 M 0.490 196.500 C 0.490 304.300, 0.607 348.252, 0.750 294.170 C 0.893 240.089, 0.893 151.889, 0.750 98.170 C 0.607 44.452, 0.490 88.700, 0.490 196.500 M 16.667 16.667 C 16.300 17.033, 16 97.808, 16 196.167 L 16 375 65 375 L 114 375 114 244.500 L 114 114 244.500 114 L 375 114 375 65 L 375 16 196.167 16 C 97.808 16, 17.033 16.300, 16.667 16.667 M 131 310.500 L 131 490 310.500 490 L 490 490 490 310.500 L 490 131 310.500 131 L 131 131 131 310.500 M 302 253 L 302 302 253 302 L 204 302 204 310 L 204 318 253 318 L 302 318 302 367 L 302 416 310 416 L 318 416 318 367 L 318 318 367 318 L 416 318 416 310 L 416 302 367 302 L 318 302 318 253 L 318 204 310 204 L 302 204 302 253" stroke="none" fill="#bada55" fill-rule="evenodd"/> |
16 | | -</svg>`; |
| 15 | +</svg>` |
17 | 16 |
|
18 | | -test("Converts from string", async (t) => { |
19 | | - const res = await outlineStroke(src); |
20 | | - t.is(res, expected); |
21 | | -}); |
| 17 | +test('Converts from string', async (t) => { |
| 18 | + const res = await outlineStroke(src) |
| 19 | + t.is(res, expected) |
| 20 | +}) |
22 | 21 |
|
23 | | -test.cb("Converts from Buffer", (t) => { |
24 | | - fs.readFile("./src.svg", (err, data) => { |
| 22 | +test.cb('Converts from Buffer', (t) => { |
| 23 | + fs.readFile('./src.svg', (err, data) => { |
25 | 24 | outlineStroke(data).then((res) => { |
26 | | - t.is(res, expected); |
27 | | - t.end(); |
28 | | - }); |
29 | | - }); |
30 | | -}); |
| 25 | + t.is(res, expected) |
| 26 | + t.end() |
| 27 | + }) |
| 28 | + }) |
| 29 | +}) |
31 | 30 |
|
32 | | -test("Apply params (color)", async (t) => { |
| 31 | +test('Apply params (color)', async (t) => { |
33 | 32 | const res = await outlineStroke(src, { |
34 | | - color: "#bada55", |
35 | | - background: "#a1a5a5", |
36 | | - }); |
37 | | - t.is(res, expectedWithParams); |
38 | | -}); |
| 33 | + color: '#bada55', |
| 34 | + background: '#a1a5a5', |
| 35 | + }) |
| 36 | + t.is(res, expectedWithParams) |
| 37 | +}) |
0 commit comments