forked from tschaub/gh-pages
-
Notifications
You must be signed in to change notification settings - Fork 1
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
3 changed files
with
111 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var chai = require('chai'); | ||
|
||
|
||
/** @type {boolean} */ | ||
chai.config.includeStack = true; | ||
|
||
|
||
/** | ||
* Chai's assert function configured to include stacks on failure. | ||
* @type {function} | ||
*/ | ||
exports.assert = chai.assert; |
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,97 @@ | ||
var path = require('path'); | ||
|
||
var assert = require('../helper').assert; | ||
|
||
var util = require('../../lib/util'); | ||
|
||
describe('util', function() { | ||
|
||
var files; | ||
beforeEach(function() { | ||
files = [ | ||
path.join('a1', 'b1', 'c2', 'd2.txt'), | ||
path.join('a1', 'b2', 'c2', 'd1.txt'), | ||
path.join('a2.txt'), | ||
path.join('a1', 'b1', 'c1', 'd1.txt'), | ||
path.join('a1', 'b1', 'c2', 'd1.txt'), | ||
path.join('a1', 'b1.txt'), | ||
path.join('a2', 'b1', 'c2.txt'), | ||
path.join('a1', 'b1', 'c2', 'd3.txt'), | ||
path.join('a1', 'b2', 'c1', 'd1.txt'), | ||
path.join('a1.txt'), | ||
path.join('a2', 'b1', 'c1.txt'), | ||
path.join('a2', 'b1.txt') | ||
].slice(); | ||
}); | ||
|
||
describe('byShortPath', function() { | ||
it('sorts an array of filepaths, shortest first', function() { | ||
files.sort(util.byShortPath); | ||
|
||
var expected = [ | ||
path.join('a1.txt'), | ||
path.join('a2.txt'), | ||
path.join('a1', 'b1.txt'), | ||
path.join('a2', 'b1.txt'), | ||
path.join('a2', 'b1', 'c1.txt'), | ||
path.join('a2', 'b1', 'c2.txt'), | ||
path.join('a1', 'b1', 'c1', 'd1.txt'), | ||
path.join('a1', 'b1', 'c2', 'd1.txt'), | ||
path.join('a1', 'b1', 'c2', 'd2.txt'), | ||
path.join('a1', 'b1', 'c2', 'd3.txt'), | ||
path.join('a1', 'b2', 'c1', 'd1.txt'), | ||
path.join('a1', 'b2', 'c2', 'd1.txt') | ||
]; | ||
|
||
assert.deepEqual(files, expected); | ||
}); | ||
}); | ||
|
||
describe('uniqueDirs', function() { | ||
|
||
it('gets a list of unique directory paths', function() { | ||
// not comparing order here, so we sort both | ||
var got = util.uniqueDirs(files).sort(); | ||
|
||
var expected = [ | ||
'.', | ||
'a1', | ||
'a2', | ||
path.join('a1', 'b1'), | ||
path.join('a1', 'b1', 'c1'), | ||
path.join('a1', 'b1', 'c2'), | ||
path.join('a1', 'b2'), | ||
path.join('a1', 'b2', 'c1'), | ||
path.join('a1', 'b2', 'c2'), | ||
path.join('a2', 'b1') | ||
].sort(); | ||
|
||
assert.deepEqual(got, expected); | ||
}); | ||
|
||
}); | ||
|
||
describe('dirsToCreate', function() { | ||
|
||
it('gets a sorted list of directories to create', function() { | ||
var got = util.dirsToCreate(files); | ||
|
||
var expected = [ | ||
'.', | ||
'a1', | ||
'a2', | ||
path.join('a1', 'b1'), | ||
path.join('a1', 'b2'), | ||
path.join('a2', 'b1'), | ||
path.join('a1', 'b1', 'c1'), | ||
path.join('a1', 'b1', 'c2'), | ||
path.join('a1', 'b2', 'c1'), | ||
path.join('a1', 'b2', 'c2') | ||
]; | ||
|
||
assert.deepEqual(got, expected); | ||
}); | ||
|
||
}); | ||
|
||
}); |