/** * Module dependencies. */ var fs = require('fs'); var path = require('path'); var assert = require('assert'); var degenerator = require('../'); describe('degenerator()', function () { describe('"expected" fixture tests', function () { fs.readdirSync(__dirname).forEach(function (n) { if ('test.js' == n) return; if (/\.expected\.js$/.test(n)) return; var expectedName = path.basename(n, '.js') + '.expected.js'; it(n + ' → ' + expectedName, function () { var sourceName = path.resolve(__dirname, n); var compiledName = path.resolve(__dirname, expectedName); var js = fs.readFileSync(sourceName, 'utf8'); var expected = fs.readFileSync(compiledName, 'utf8'); // the test case can define the `names` to use as a // comment on the first line of the file var names = js.match(/\/\/\s*(.*)/); if (names) { // the comment should be a comma-separated list of function names names = names[1].split(/,\s*/); } else { // if no function names were passed in then convert them all names = [ /.*/ ]; } var compiled = degenerator(js, names); assert.equal(expected.trim(), compiled.trim()); }); }); }); });
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
basic.expected.js | File | 64 B | 0644 |
|
basic.js | File | 46 B | 0644 |
|
get-example.expected.js | File | 234 B | 0644 |
|
get-example.js | File | 185 B | 0644 |
|
multiple.expected.js | File | 135 B | 0644 |
|
multiple.js | File | 120 B | 0644 |
|
pac-resolver-gh-16.expected.js | File | 857 B | 0644 |
|
pac-resolver-gh-16.js | File | 832 B | 0644 |
|
pac-resolver-gh-3.expected.js | File | 625 B | 0644 |
|
pac-resolver-gh-3.js | File | 683 B | 0644 |
|
test.js | File | 1.26 KB | 0644 |
|