From 63e5ecafea58db145f6d9bf46623c1859995c850 Mon Sep 17 00:00:00 2001 From: Varya Stepanova Date: Thu, 27 Nov 2014 17:55:10 +0200 Subject: [PATCH 1/5] [fix] Depend on Gonzales 3.0.0-12 (Fixed dealign with variables in Bootstrap) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 71511e62..736f531c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "event-stream": "^3.1.7", "express": "^4.10.1", "gonzales-ast": "0.0.5", - "gonzales-pe": "^3.0.0-11", + "gonzales-pe": "^3.0.0-12", "gulp": "^3.8.10", "gulp-bower": "^0.0.7", "gulp-concat": "^2.4.1", From f58f7cc909061f40fbe3b8fa2c5c8bf70652beec Mon Sep 17 00:00:00 2001 From: Varya Stepanova Date: Fri, 28 Nov 2014 10:39:16 +0200 Subject: [PATCH 2/5] Test on parsing problematic Bootsrap variables --- test/unit/vendors/gonzales.test.js | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 test/unit/vendors/gonzales.test.js diff --git a/test/unit/vendors/gonzales.test.js b/test/unit/vendors/gonzales.test.js new file mode 100644 index 00000000..31d91a6e --- /dev/null +++ b/test/unit/vendors/gonzales.test.js @@ -0,0 +1,82 @@ +var requireModule = require('requirefrom')('lib/modules'), + gulp = require('gulp'), + chai = require('chai'), + expect = chai.expect, + multiline = require('multiline'), + gonzales = require('gonzales-pe'); + +var util = require('util'); + +describe('Gonzales', function() { + + describe('Should parse Bootsrap variables', function() { + var str = multiline(function() { + /* +$bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")')) !default; +$font-size-large: ceil(($font-size-base * 1.25)) !default; // ~18px + */ + }), + result = [ 'stylesheet', + [ 'declaration', + [ 'property', + [ 'variable', [ 'ident', 'bootstrap-sass-asset-helper' ] ] ], + [ 'propertyDelim' ], + [ 's', ' ' ], + [ 'value', + [ 'braces', + '(', + ')', + [ 'function', + [ 'ident', 'twbs-font-path' ], + [ 'arguments', [ 'string', '""' ] ] ], + [ 's', ' ' ], + [ 'operator', '!=' ], + [ 's', ' ' ], + [ 'function', + [ 'ident', 'unquote' ], + [ 'arguments', [ 'string', '\'twbs-font-path("")\'' ] ] ] ], + [ 's', ' ' ], + [ 'default' ] ] ], + [ 'declDelim' ], + [ 's', '\n' ], + [ 'declaration', + [ 'property', [ 'variable', [ 'ident', 'font-size-large' ] ] ], + [ 'propertyDelim' ], + [ 's', ' ' ], + [ 'value', + [ 'function', + [ 'ident', 'ceil' ], + [ 'arguments', + [ 'braces', + '(', + ')', + [ 'variable', [ 'ident', 'font-size-base' ] ], + [ 's', ' ' ], + [ 'ident', '*' ], + [ 's', ' ' ], + [ 'number', '1.25' ] ] ] ], + [ 's', ' ' ], + [ 'default' ] ] ], + [ 'declDelim' ], + [ 's', ' ' ], + [ 'commentSL', ' ~18px' ] ]; + + it('SASS', function(){ + ast = gonzales.srcToAST({ + src: str, + syntax: 'sass' + }); + expect(ast).eql(result); + }); + + it('SCSS', function(){ + ast = gonzales.srcToAST({ + src: str, + syntax: 'scss' + }); + expect(ast).eql(result); + }); + + }); + +}); From 282f46cbd575e4118ea7f6f2e08549d0724fcd04 Mon Sep 17 00:00:00 2001 From: Varya Stepanova Date: Fri, 28 Nov 2014 10:41:29 +0200 Subject: [PATCH 3/5] Do not check tests for Gonzales --- .jscsrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.jscsrc b/.jscsrc index 5660fa32..60abae29 100644 --- a/.jscsrc +++ b/.jscsrc @@ -13,6 +13,7 @@ "lib/dist/**", "lib/app/js/components/**", "lib/modules/kss-blocks-parser.js", - "test/unit/modules/kss-splitter.test.js" // Does not allow multiple linebreaks in comments + "test/unit/modules/kss-splitter.test.js", // Does not allow multiple linebreaks in comments + "test/unit/vendors/gonzales.test.js" // Does not allow multiple linebreaks in comments ] } From caa3e3e86abd5f2169ae5a281ed6a7d11d38b7b0 Mon Sep 17 00:00:00 2001 From: Varya Stepanova Date: Fri, 28 Nov 2014 10:43:14 +0200 Subject: [PATCH 4/5] Syntax --- test/unit/vendors/gonzales.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/vendors/gonzales.test.js b/test/unit/vendors/gonzales.test.js index 31d91a6e..f185eb45 100644 --- a/test/unit/vendors/gonzales.test.js +++ b/test/unit/vendors/gonzales.test.js @@ -61,7 +61,7 @@ $font-size-large: ceil(($font-size-base * 1.25)) !default; // ~18px [ 's', ' ' ], [ 'commentSL', ' ~18px' ] ]; - it('SASS', function(){ + it('SASS', function() { ast = gonzales.srcToAST({ src: str, syntax: 'sass' @@ -69,7 +69,7 @@ $font-size-large: ceil(($font-size-base * 1.25)) !default; // ~18px expect(ast).eql(result); }); - it('SCSS', function(){ + it('SCSS', function() { ast = gonzales.srcToAST({ src: str, syntax: 'scss' From d367f4438e909bdbf9289a06656b94acb019306f Mon Sep 17 00:00:00 2001 From: Varya Stepanova Date: Fri, 28 Nov 2014 11:19:34 +0200 Subject: [PATCH 5/5] Make tests on Gonzales more atomic --- test/unit/vendors/gonzales.test.js | 105 +++++++++++++---------------- 1 file changed, 48 insertions(+), 57 deletions(-) diff --git a/test/unit/vendors/gonzales.test.js b/test/unit/vendors/gonzales.test.js index f185eb45..a2070226 100644 --- a/test/unit/vendors/gonzales.test.js +++ b/test/unit/vendors/gonzales.test.js @@ -5,78 +5,69 @@ var requireModule = require('requirefrom')('lib/modules'), multiline = require('multiline'), gonzales = require('gonzales-pe'); -var util = require('util'); - describe('Gonzales', function() { - describe('Should parse Bootsrap variables', function() { - var str = multiline(function() { - /* -$bootstrap-sass-asset-helper: (twbs-font-path("") != unquote('twbs-font-path("")')) !default; -$font-size-large: ceil(($font-size-base * 1.25)) !default; // ~18px - */ - }), - result = [ 'stylesheet', - [ 'declaration', - [ 'property', - [ 'variable', [ 'ident', 'bootstrap-sass-asset-helper' ] ] ], - [ 'propertyDelim' ], - [ 's', ' ' ], - [ 'value', - [ 'braces', - '(', - ')', - [ 'function', - [ 'ident', 'twbs-font-path' ], - [ 'arguments', [ 'string', '""' ] ] ], - [ 's', ' ' ], - [ 'operator', '!=' ], - [ 's', ' ' ], - [ 'function', - [ 'ident', 'unquote' ], - [ 'arguments', [ 'string', '\'twbs-font-path("")\'' ] ] ] ], - [ 's', ' ' ], - [ 'default' ] ] ], - [ 'declDelim' ], - [ 's', '\n' ], - [ 'declaration', - [ 'property', [ 'variable', [ 'ident', 'font-size-large' ] ] ], - [ 'propertyDelim' ], - [ 's', ' ' ], - [ 'value', - [ 'function', - [ 'ident', 'ceil' ], - [ 'arguments', - [ 'braces', - '(', - ')', - [ 'variable', [ 'ident', 'font-size-base' ] ], - [ 's', ' ' ], - [ 'ident', '*' ], - [ 's', ' ' ], - [ 'number', '1.25' ] ] ] ], - [ 's', ' ' ], - [ 'default' ] ] ], - [ 'declDelim' ], - [ 's', ' ' ], - [ 'commentSL', ' ~18px' ] ]; + describe('SASS', function() { + + it('Should take inequality', function() { + var str = multiline(function() { + /* +$a: 1 != 2; + */ + }); - it('SASS', function() { ast = gonzales.srcToAST({ src: str, syntax: 'sass' }); - expect(ast).eql(result); + expect(ast).to.be.an('array'); }); - it('SCSS', function() { + it('Should take multiple braces in functions', function() { + var str = multiline(function() { + /* +$a: cell((1.75)); + */ + }); + + ast = gonzales.srcToAST({ + src: str, + syntax: 'sass' + }); + expect(ast).to.be.an('array'); + }); + + }); + + describe('SCSS', function() { + + it('Should take inequality', function() { + var str = multiline(function() { + /* +$a: 1 != 2; + */ + }); + ast = gonzales.srcToAST({ src: str, syntax: 'scss' }); - expect(ast).eql(result); + expect(ast).to.be.an('array'); }); + it('Should take multiple braces in functions', function() { + var str = multiline(function() { + /* +$a: cell((1.75)); + */ + }); + + ast = gonzales.srcToAST({ + src: str, + syntax: 'scss' + }); + expect(ast).to.be.an('array'); + }); }); });