1 |
|
2 |
|
3 | const chai = require('chai');
|
4 | const join = require('path').join;
|
5 | const execSync = require('child_process').execSync;
|
6 | const fs = require('fs');
|
7 |
|
8 | const assert = chai.assert;
|
9 | chai.use(require('chai-fs'));
|
10 |
|
11 | describe('Sass Export Data', function() {
|
12 | this.timeout(5000);
|
13 | let output = '';
|
14 | before(() => {
|
15 | try {
|
16 | output = execSync('npm run test:compile', {
|
17 | cwd: __dirname,
|
18 | encoding: 'utf8',
|
19 | });
|
20 |
|
21 | } catch (e) {
|
22 | console.error('Could not run command beforehand.', e);
|
23 | }
|
24 | });
|
25 |
|
26 | fs.readdirSync(join(__dirname, './basics/expected'))
|
27 | .filter(file => file.endsWith('json'))
|
28 | .forEach(file => {
|
29 | it(`Creates JSON from Sass Vars in ${file}`, () => {
|
30 | assert.deepEqual(
|
31 | JSON.parse(
|
32 | fs.readFileSync(join(__dirname, './basics/dest/', file), 'utf8'),
|
33 | ),
|
34 | JSON.parse(
|
35 | fs.readFileSync(
|
36 | join(__dirname, './basics/expected/', file),
|
37 | 'utf8',
|
38 | ),
|
39 | ),
|
40 | `JSON files do not match.\n\n${output}`,
|
41 | );
|
42 | });
|
43 | });
|
44 | });
|