UNPKG

1.21 kBJavaScriptView Raw
1/* global describe, it, before */
2/* eslint-disable import/no-extraneous-dependencies, func-names */
3const chai = require('chai');
4const join = require('path').join;
5const execSync = require('child_process').execSync;
6const fs = require('fs');
7
8const assert = chai.assert;
9chai.use(require('chai-fs'));
10
11describe('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 // console.log(output);
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});