forked from csscomb/csscomb.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
279 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
let assert = require('assert'); | ||
let fs = require('fs'); | ||
let path = require('path'); | ||
|
||
let Comb = require('../../lib/csscomb'); | ||
|
||
class CoreTest { | ||
constructor(context, config) { | ||
this.file = context.test.file; | ||
this.syntax = context.test.parent.title; | ||
|
||
this.Comb = Comb; | ||
this.comb = new Comb(); | ||
if (config) this.comb.configure(config); | ||
} | ||
|
||
useConfig(name) { | ||
let config = Comb.getConfig(name); | ||
this.comb.configure(config); | ||
} | ||
|
||
getErrors(filename) { | ||
let input = this.readFile(filename); | ||
return this.comb.lintString(input, {syntax: this.syntax}); | ||
} | ||
|
||
shouldBeEqual(inputFile, expectedFile) { | ||
let input = this.readFile(inputFile); | ||
let expected = expectedFile ? this.readFile(expectedFile) : input; | ||
|
||
return this.comb.processString(input, {syntax: this.syntax}) | ||
.then(string => assert.equal(string, expected)); | ||
} | ||
|
||
/** | ||
* Detect options in a file and compare result with expected. | ||
* File names should be relative to test suite's folder. | ||
* @param {Array} options List of options that should be detected | ||
* @param {String} input Name of template file | ||
* @param {Object} expected Expected config with detected options | ||
*/ | ||
shouldDetect(options, input, expected) { | ||
let detectedConfig = Comb.detectInString(input, options); | ||
assert.deepEqual(detectedConfig, expected); | ||
} | ||
|
||
readFile(filename) { | ||
let dirname = path.dirname(this.file); | ||
let filePath = path.join(dirname, filename); | ||
return fs.readFileSync(filePath, 'utf8'); | ||
} | ||
} | ||
|
||
module.exports = CoreTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,63 @@ | ||
var assert = require('assert'); | ||
let Test = require('../core_test'); | ||
|
||
describe.skip('csscomb methods', function() { | ||
describe('csscomb methods', function() { | ||
it('getConfig()', function() { | ||
let test = new Test(this); | ||
var config = require('../../../config/csscomb.json'); | ||
|
||
assert.equal(this.Comb.getConfig(), config); | ||
assert.equal(test.Comb.getConfig(), config); | ||
}); | ||
|
||
it('getConfig(number)', function() { | ||
let test = new Test(this); | ||
|
||
assert.throws(function() { | ||
this.Comb.getConfig(16); | ||
test.Comb.getConfig(16); | ||
}); | ||
}); | ||
|
||
it('getConfig(boolean)', function() { | ||
let test = new Test(this); | ||
|
||
assert.throws(function() { | ||
this.Comb.getConfig(true); | ||
test.Comb.getConfig(true); | ||
}); | ||
}); | ||
|
||
it('getConfig(empty string)', function() { | ||
let test = new Test(this); | ||
var config = require('../../../config/csscomb.json'); | ||
|
||
assert.equal(this.Comb.getConfig(''), config); | ||
assert.equal(test.Comb.getConfig(''), config); | ||
}); | ||
|
||
it('getConfig(invalid string)', function() { | ||
let test = new Test(this); | ||
|
||
assert.throws(function() { | ||
this.Comb.getConfig('nani'); | ||
test.Comb.getConfig('nani'); | ||
}); | ||
}); | ||
|
||
it('getConfig(csscomb)', function() { | ||
let test = new Test(this); | ||
var config = require('../../../config/csscomb.json'); | ||
|
||
assert.equal(this.Comb.getConfig('csscomb'), config); | ||
assert.equal(test.Comb.getConfig('csscomb'), config); | ||
}); | ||
|
||
it('getConfig(zen)', function() { | ||
let test = new Test(this); | ||
var config = require('../../../config/zen.json'); | ||
|
||
assert.equal(this.Comb.getConfig('zen'), config); | ||
assert.equal(test.Comb.getConfig('zen'), config); | ||
}); | ||
|
||
it('getConfig(yandex)', function() { | ||
let test = new Test(this); | ||
var config = require('../../../config/yandex.json'); | ||
|
||
assert.equal(this.Comb.getConfig('yandex'), config); | ||
assert.equal(test.Comb.getConfig('yandex'), config); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,66 @@ | ||
describe.skip('LESS', function() { | ||
beforeEach(function() { | ||
this.comb.configure({}); | ||
}); | ||
let Test = require('../core_test'); | ||
|
||
describe('less', function() { | ||
it('Should parse nested rules', function() { | ||
this.shouldBeEqual('nested-rule.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('nested-rule.less'); | ||
}); | ||
|
||
it('Should parse operations', function() { | ||
this.shouldBeEqual('operation.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('operation.less'); | ||
}); | ||
|
||
it('Should parse parent selector &', function() { | ||
this.shouldBeEqual('parent-selector.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('parent-selector.less'); | ||
}); | ||
|
||
it('Should parse variables', function() { | ||
this.shouldBeEqual('variable.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('variable.less'); | ||
}); | ||
|
||
it('Should parse interpolated variables inside selectors', function() { | ||
this.shouldBeEqual('interpolated-variable-1.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('interpolated-variable-1.less'); | ||
}); | ||
|
||
it('Should parse interpolated variables inside values', function() { | ||
this.shouldBeEqual('interpolated-variable-2.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('interpolated-variable-2.less'); | ||
}); | ||
|
||
it('Should parse @import', function() { | ||
this.shouldBeEqual('import.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('import.less'); | ||
}); | ||
|
||
it('Should parse included mixins', function() { | ||
this.shouldBeEqual('mixin.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('mixin.less'); | ||
}); | ||
|
||
it('Should parse nested @media', function() { | ||
this.shouldBeEqual('nested-media.less'); | ||
let test = new Test(this); | ||
test.comb.configure({}); | ||
|
||
return test.shouldBeEqual('nested-media.less'); | ||
}); | ||
}); |
Oops, something went wrong.