mirror of
https://github.com/scratchfoundation/gh-pages.git
synced 2025-02-17 16:10:17 -05:00
commit
2824fd7ee9
5 changed files with 117 additions and 1 deletions
4
.travis.yml
Normal file
4
.travis.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.8"
|
|
@ -41,6 +41,7 @@
|
|||
"devDependencies": {
|
||||
"glob": "~3.2.9",
|
||||
"mocha": "~1.18.2",
|
||||
"jshint": "~2.4.4"
|
||||
"jshint": "~2.4.4",
|
||||
"chai": "~1.9.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,3 +3,5 @@
|
|||
Publish files to a `gh-pages` branch on GitHub (or any other branch anywhere else).
|
||||
|
||||
This will evolve into a more useful package. For now, it's just some extracted bits from the [`grunt-gh-pages`](https://www.npmjs.org/package/grunt-gh-pages) package.
|
||||
|
||||
[![Current Status](https://secure.travis-ci.org/tschaub/gh-pages.png?branch=master)](https://travis-ci.org/tschaub/gh-pages)
|
||||
|
|
12
test/helper.js
Normal file
12
test/helper.js
Normal file
|
@ -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;
|
97
test/lib/util.spec.js
Normal file
97
test/lib/util.spec.js
Normal file
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in a new issue