1 |
|
2 | 'use strict';
|
3 |
|
4 | const fs = require('fs');
|
5 | const path = require('path');
|
6 | const assert = require('assert');
|
7 | const childProcess = require('child_process');
|
8 |
|
9 | describe('Testing CLI', () => {
|
10 | it('should work for simple SVG', (done) => {
|
11 | const command =
|
12 | `${'node' + ' '}${path.join(
|
13 | __dirname,
|
14 | '..',
|
15 | 'bin',
|
16 | 'svgicons2svgfont.js'
|
17 | )} -o ${path.join(
|
18 | __dirname,
|
19 | 'results',
|
20 | 'originalicons-cli.svg'
|
21 | )} -s 0xE001` +
|
22 | ` ${path.join(__dirname, 'fixtures', 'originalicons', '*.svg')}`;
|
23 |
|
24 | childProcess.exec(command, (err) => {
|
25 | if (err) {
|
26 | throw err;
|
27 | }
|
28 | assert.equal(
|
29 | fs.readFileSync(
|
30 | path.join(__dirname, 'results', 'originalicons-cli.svg'),
|
31 | { encoding: 'utf8' }
|
32 | ),
|
33 | fs.readFileSync(
|
34 | path.join(__dirname, 'expected', 'originalicons-cli.svg'),
|
35 | { encoding: 'utf8' }
|
36 | )
|
37 | );
|
38 | done();
|
39 | });
|
40 | });
|
41 |
|
42 | it('should work for more than 32 SVG icons', (done) => {
|
43 | const command =
|
44 | 'node' +
|
45 | ' ' +
|
46 | path.join(__dirname, '..', 'bin', 'svgicons2svgfont.js') +
|
47 | ' -o ' +
|
48 | path.join(__dirname, 'results', 'lotoficons-cli.svg') +
|
49 | ' -s 0xE001' +
|
50 | ' -r 1e4' +
|
51 | ' ' +
|
52 | path.join(__dirname, 'fixtures', 'cleanicons', '*.svg') +
|
53 | ' ' +
|
54 | path.join(__dirname, 'fixtures', 'hiddenpathesicons', '*.svg') +
|
55 | ' ' +
|
56 | path.join(__dirname, 'fixtures', 'multipathicons', 'kikoolol.svg') +
|
57 | ' ' +
|
58 | path.join(__dirname, 'fixtures', 'originalicons', '*.svg') +
|
59 | ' ' +
|
60 | path.join(__dirname, 'fixtures', 'realicons', '*.svg') +
|
61 | ' ' +
|
62 | path.join(__dirname, 'fixtures', 'roundedcorners', '*.svg') +
|
63 | ' ' +
|
64 | path.join(__dirname, 'fixtures', 'shapeicons', '*.svg') +
|
65 | ' ' +
|
66 | path.join(__dirname, 'fixtures', 'tocentericons', '*.svg');
|
67 |
|
68 | childProcess.exec(command, (err) => {
|
69 | if (err) {
|
70 | throw err;
|
71 | }
|
72 | assert.equal(
|
73 | fs.readFileSync(path.join(__dirname, 'results', 'lotoficons-cli.svg'), {
|
74 | encoding: 'utf8',
|
75 | }),
|
76 | fs.readFileSync(
|
77 | path.join(__dirname, 'expected', 'lotoficons-cli.svg'),
|
78 | { encoding: 'utf8' }
|
79 | )
|
80 | );
|
81 | done();
|
82 | });
|
83 | });
|
84 |
|
85 | describe('with nested icons', () => {
|
86 | it('should work', (done) => {
|
87 | const command = `${'node' + ' '}${path.join(
|
88 | __dirname,
|
89 | '..',
|
90 | 'bin',
|
91 | 'svgicons2svgfont.js'
|
92 | )} -o ${path.join(
|
93 | __dirname,
|
94 | 'results',
|
95 | 'nestedicons-cli.svg'
|
96 | )} ${path.join(__dirname, 'fixtures', 'nestedicons', '*.svg')}`;
|
97 |
|
98 | childProcess.exec(command, (err) => {
|
99 | if (err) {
|
100 | throw err;
|
101 | }
|
102 | assert.equal(
|
103 | fs.readFileSync(
|
104 | path.join(__dirname, 'results', 'nestedicons-cli.svg'),
|
105 | { encoding: 'utf8' }
|
106 | ),
|
107 | fs.readFileSync(
|
108 | path.join(__dirname, 'expected', 'nestedicons-cli.svg'),
|
109 | { encoding: 'utf8' }
|
110 | )
|
111 | );
|
112 | done();
|
113 | });
|
114 | });
|
115 | });
|
116 | });
|