-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
index.test.js
81 lines (76 loc) · 2.13 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
69
70
71
72
73
74
75
76
77
78
79
80
81
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import pkg from '../package.json';
// const __filename = fileURLToPath(import.meta.url);
// const __dirname = path.dirname(__filename);
// const pkg = fs.readJSONSync(path.resolve(__dirname, "../package.json"));
// const fs = require('fs-extra');
// const path = require('path');
// const svgtofont = require('../lib/index.js');
it('example test case.', async () => {
const dist = path.resolve(process.cwd(), 'examples', 'example', 'dist');
const fileNames = await fs.readdir(dist);
expect(fileNames).toEqual([
'font-class.html',
'index.html',
'react',
'reactNative',
'svgtofont.css',
'svgtofont.d.ts',
'svgtofont.eot',
'svgtofont.json',
'svgtofont.less',
'svgtofont.module.less',
'svgtofont.scss',
'svgtofont.styl',
'svgtofont.svg',
'svgtofont.symbol.svg',
'svgtofont.ttf',
'svgtofont.woff',
'svgtofont.woff2',
'symbol.html'
]);
});
it('example simple test case.', async () => {
const dist = path.resolve(process.cwd(), 'examples', 'example', 'example');
const fileNames = await fs.readdir(dist);
expect(fileNames).toEqual([
'svgtofont.css',
'svgtofont.eot',
'svgtofont.less',
'svgtofont.module.less',
'svgtofont.scss',
'svgtofont.styl',
'svgtofont.svg',
'svgtofont.symbol.svg',
'svgtofont.ttf',
'svgtofont.woff',
'svgtofont.woff2',
]);
})
it('templates templates test case.', async () => {
const dist = path.resolve(process.cwd(), 'examples', 'templates', 'dist2');
const fileNames = await fs.readdir(dist);
expect(fileNames).toEqual([
'font-class.html',
'index.html',
'react',
'reactNative',
'svgtofont.css',
'svgtofont.eot',
'svgtofont.json',
'svgtofont.less',
'svgtofont.module.less',
'svgtofont.scss',
'svgtofont.styl',
'svgtofont.svg',
'svgtofont.symbol.svg',
'svgtofont.ttf',
'svgtofont.woff',
'svgtofont.woff2',
'symbol.html'
]);
const css = await fs.readFile(path.resolve(dist, 'svgtofont.css'));
expect(css.toString().indexOf('Hello CSS!') > -1).toBeTruthy();
})