-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
16 changed files
with
226 additions
and
5 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
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,89 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2016 Titus Wormer | ||
* @license MIT | ||
* @module unified-engine | ||
* @fileoverview Test suite for `unified-engine`. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/* Dependencies. */ | ||
var path = require('path'); | ||
var test = require('tape'); | ||
var noop = require('./util/noop-processor'); | ||
var spy = require('./util/spy'); | ||
var engine = require('..'); | ||
|
||
/* Methods. */ | ||
var join = path.join; | ||
|
||
/* Constants. */ | ||
var fixtures = join(__dirname, 'fixtures'); | ||
|
||
/* Tests. */ | ||
test('`configTransform`', function (t) { | ||
t.plan(1); | ||
|
||
t.test('should work', function (st) { | ||
var stderr = spy(); | ||
|
||
st.plan(7); | ||
|
||
engine({ | ||
processor: noop.use(function (processor) { | ||
processor.t = st; | ||
}), | ||
streamError: stderr.stream, | ||
cwd: join(fixtures, 'config-transform'), | ||
globs: ['.'], | ||
rcName: '.foorc', | ||
packageField: 'foo', | ||
configTransform: configTransform, | ||
extensions: ['txt'] | ||
}, function (err, code, result) { | ||
var cache = result.configuration.cache; | ||
var keys = Object.keys(cache); | ||
|
||
st.error(err, 'should not fail fatally'); | ||
st.equal(code, 0, 'should exit with `0`'); | ||
st.equal(keys.length, 1, 'should have one cache entry'); | ||
|
||
st.deepEqual( | ||
cache[keys[0]].settings, | ||
{ | ||
charlie: true, | ||
bravo: true, | ||
alpha: true, | ||
foxtrot: true, | ||
echo: true, | ||
delta: true | ||
}, | ||
'should set the correct settings' | ||
); | ||
|
||
st.deepEqual( | ||
cache[keys[0]].plugins[join(fixtures, 'config-transform', 'test.js')], | ||
{ | ||
package: ['foo', 'bar', 'baz'], | ||
cascade: 5, | ||
script: true, | ||
nestedScript: true | ||
}, | ||
'should pass the correct options to plugins' | ||
); | ||
|
||
st.equal( | ||
stderr(), | ||
'nested/one.txt: no issues found\n' | ||
); | ||
}); | ||
|
||
function configTransform(raw) { | ||
return { | ||
settings: raw.options, | ||
plugins: raw.plugs | ||
}; | ||
} | ||
}); | ||
}); |
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,6 @@ | ||
{ | ||
"options": { | ||
"alpha": true | ||
}, | ||
"plugs": ["./test"] | ||
} |
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,11 @@ | ||
module.exports = { | ||
options: { | ||
bravo: true | ||
}, | ||
plugs: { | ||
'./test': { | ||
script: true, | ||
cascade: 1 | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"options": { | ||
"delta": true | ||
}, | ||
"plugs": [ | ||
"./test" | ||
] | ||
} |
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,10 @@ | ||
module.exports.plugs = { | ||
'./test': { | ||
nestedScript: true, | ||
cascade: 5 | ||
} | ||
}; | ||
|
||
module.exports.options = { | ||
echo: true | ||
}; |
Empty file.
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,10 @@ | ||
{ | ||
"foo": { | ||
"options": { | ||
"foxtrot": true | ||
}, | ||
"plugs": { | ||
"./test": null | ||
} | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"foo": { | ||
"options": { | ||
"charlie": true | ||
}, | ||
"plugs": { | ||
"./test": { | ||
"package": ["foo", "bar", "baz"], | ||
"cascade": 2 | ||
} | ||
} | ||
} | ||
} |
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,12 @@ | ||
module.exports = function (processor, options) { | ||
processor.t.deepEqual( | ||
options, | ||
{ | ||
script: true, | ||
package: ['foo', 'bar', 'baz'], | ||
nestedScript: true, | ||
cascade: 5 | ||
}, | ||
'should pass the correct options to plugin `test`' | ||
); | ||
} |
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