From 33d2de19fbfa295292980db5d94a573c6cfbb15b Mon Sep 17 00:00:00 2001 From: Daksh Shah Date: Thu, 26 Oct 2017 23:50:24 +0530 Subject: [PATCH] Source Code: Renamed globals key to variables --- src/app/converter/converter-buffers.test.ts | 6 +++--- src/app/converter/converter.test.ts | 18 ++++++++--------- src/app/parser/parser.test.ts | 22 ++++++++++----------- src/app/parser/parser.ts | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/app/converter/converter-buffers.test.ts b/src/app/converter/converter-buffers.test.ts index 5bd6583..2306c33 100644 --- a/src/app/converter/converter-buffers.test.ts +++ b/src/app/converter/converter-buffers.test.ts @@ -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); }); @@ -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); }); }); diff --git a/src/app/converter/converter.test.ts b/src/app/converter/converter.test.ts index c473cd7..6d97716 100644 --- a/src/app/converter/converter.test.ts +++ b/src/app/converter/converter.test.ts @@ -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 @@ -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'); }); }); @@ -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'); }); }); @@ -143,7 +143,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'); }); it('should compile values inside a map', () => { @@ -151,9 +151,9 @@ describe('Converter class', () => { 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', () => { @@ -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'); }); diff --git a/src/app/parser/parser.test.ts b/src/app/parser/parser.test.ts index 107437a..91b0b4b 100644 --- a/src/app/parser/parser.test.ts +++ b/src/app/parser/parser.test.ts @@ -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', () => { @@ -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].variable).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" @@ -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].variable).be.equal('brand-gray-light'); }); @@ -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', () => { @@ -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', () => { @@ -164,10 +164,10 @@ describe('Parser class', () => { let parser = new Parser(content); let structured = parser.parseStructured(); - expect(structured.globals[0].mapValue[0].variable).be.equal('small'); - expect(structured.globals[0].mapValue[0].value).be.equal('767px'); + expect(structured.variables[0].mapValue[0].variable).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', () => { diff --git a/src/app/parser/parser.ts b/src/app/parser/parser.ts index 43f3dec..06e3f24 100644 --- a/src/app/parser/parser.ts +++ b/src/app/parser/parser.ts @@ -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 {