Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/converter/converter-buffers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('buffers support', () => {

converter.getData().then((result) => {
expect(result).that.is.an('object');
expect(result.globals[0]).to.have.property('compiledValue');
expect(result.variables[0]).to.have.property('compiledValue');
}).catch((err: Error) => {
console.log('error', err.message);
});
Expand All @@ -36,8 +36,8 @@ describe('buffers support', () => {

converter.getData().then((result) => {
expect(result).that.is.an('object');
expect(result.globals[0]).to.have.property('compiledValue');
expect(result.globals).length.greaterThan(0);
expect(result.variables[0]).to.have.property('compiledValue');
expect(result.variables).length.greaterThan(0);
});
});

Expand Down
18 changes: 9 additions & 9 deletions src/app/converter/converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ describe('Converter class', () => {
let converter = new Converter(opts);
let structured = converter.getStructured();

// globals
expect(structured.globals[0]).to.have.property('compiledValue');
// variables
expect(structured.variables[0]).to.have.property('compiledValue');
// brand-colors
expect(structured['brand-colors'][0]).to.have.property('compiledValue');
// darkens
Expand All @@ -123,7 +123,7 @@ describe('Converter class', () => {
let converter = new Converter(opts);
let structured = converter.getStructured();

expect(structured.globals[0]).to.have.property('compiledValue');
expect(structured.variables[0]).to.have.property('compiledValue');
});
});

Expand All @@ -133,7 +133,7 @@ describe('Converter class', () => {
let converter = new Converter(opts);
let structured = converter.getStructured();

expect(structured.globals[0]).to.have.property('compiledValue');
expect(structured.variables[0]).to.have.property('compiledValue');
});
});

Expand All @@ -143,17 +143,17 @@ describe('Converter class', () => {
let converter = new Converter(opts);
let structured = converter.getStructured();

expect(structured.globals[0]).to.have.property('compiledValue');
expect(structured.variables[0]).to.have.property('compiledValue');
});

it('should compile values inside a map', () => {
let opts = { inputFiles: path.resolve('./test/scss/_maps.scss'), includePaths: [] };
let converter = new Converter(opts);
let structured = converter.getStructured();

expect(structured.globals[0]).to.have.property('compiledValue');
expect(structured.globals[0]).to.have.property('mapValue');
expect(structured.globals[0].mapValue[0]).to.have.property('compiledValue');
expect(structured.variables[0]).to.have.property('compiledValue');
expect(structured.variables[0]).to.have.property('mapValue');
expect(structured.variables[0].mapValue[0]).to.have.property('compiledValue');
});

it('should compile values inside a map as array also', () => {
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('Converter class', () => {
let structured = converter.getStructured();

expect(structured).to.have.property('mixins');
expect(structured).to.have.property('globals');
expect(structured).to.have.property('variables');
expect(structured).to.have.property('fonts');
});

Expand Down
22 changes: 11 additions & 11 deletions src/app/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ describe('Parser class', () => {
expect(structured).to.be.empty;
});

it('should be globals property', () => {
it('should be variables property', () => {
let content = `$black: #000;
$white: #fff;`;
let parser = new Parser(content);
let structured = parser.parseStructured();

expect(structured).to.be.an('object');
expect(structured).to.have.property('globals');
expect(structured.globals.length).be.equal(2);
expect(structured).to.have.property('variables');
expect(structured.variables.length).be.equal(2);
});

it('should create a property if a section is present', () => {
Expand All @@ -72,12 +72,12 @@ describe('Parser class', () => {
let structured = parser.parseStructured();

expect(structured).to.have.property('theme-colors');
expect(structured.globals.length).be.equal(2);
expect(structured.variables.length).be.equal(2);
expect(structured['theme-colors'].length).be.equal(3);
expect(structured['theme-colors'][1].name).to.be.equal('brand-gray-medium');
});

it('should group in globals if end-section is present', () => {
it('should group in variables if end-section is present', () => {
let content = `$black: #000;
$white: #fff;
//@sass-export-section="light"
Expand All @@ -89,7 +89,7 @@ describe('Parser class', () => {
let structured = parser.parseStructured();

expect(structured).to.have.property('light');
expect(structured.globals.length).be.equal(4);
expect(structured.variables.length).be.equal(4);
expect(structured.light.length).be.equal(1);
expect(structured.light[0].name).be.equal('brand-gray-light');
});
Expand All @@ -104,7 +104,7 @@ describe('Parser class', () => {

let parser = new Parser(content);
let structured = parser.parseStructured();
expect(structured.globals.length).be.equal(2);
expect(structured.variables.length).be.equal(2);
});

it('should allow JSON friendly names only for section name', () => {
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('Parser class', () => {
let parser = new Parser(content);
let structured = parser.parseStructured();

expect(structured.globals[0].mapValue).that.is.an('array');
expect(structured.variables[0].mapValue).that.is.an('array');
});

it('should have a structured result', () => {
Expand All @@ -164,10 +164,10 @@ describe('Parser class', () => {
let parser = new Parser(content);
let structured = parser.parseStructured();

expect(structured.globals[0].mapValue[0].name).be.equal('small');
expect(structured.globals[0].mapValue[0].value).be.equal('767px');
expect(structured.variables[0].mapValue[0].name).be.equal('small');
expect(structured.variables[0].mapValue[0].value).be.equal('767px');

expect(structured.globals[0].mapValue[1].value).be.equal('$bp-medium');
expect(structured.variables[0].mapValue[1].value).be.equal('$bp-medium');
});

it('should have a structured result for array type', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const SECTION_TAG = 'sass-export-section';
const SECTION_PATTERN = `(@${SECTION_TAG}=)(".+")`;
const END_SECTION_PATTERN = `(@end-${SECTION_TAG})`;

const DEFAULT_SECTION = 'globals';
const DEFAULT_SECTION = 'variables';


export class Parser {
Expand Down