Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
Add unit test for 'deploy'. Fixes #34
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Castelluccio committed Oct 12, 2015
1 parent 6ad1ad2 commit a739d4f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
},
"devDependencies": {
"chai": "^3.3.0",
"fs-extra": "^0.24.0",
"gulp-mocha": "^2.1.3",
"mocha": "^2.3.3"
"mocha": "^2.3.3",
"simple-git": "^1.11.0"
},
"engines": {
"node": ">= 0.12"
Expand Down
41 changes: 41 additions & 0 deletions test/testDeploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var assert = require('assert');
var fs = require('fs');
var fse = require('fs-extra');
var path = require('path');
var deploy = require('../lib/deploy');

describe('Deploy', function() {
it('should create a gh-pages branch in the origin repo and publish files to it', function(done) {
fs.mkdirSync('tmp');

function finish(err) {
fse.removeSync('tmp');
done(err);
}

var simpleGit = require('simple-git')('tmp');

simpleGit.init(function() {
fs.writeFileSync('tmp/file', 'data');

return simpleGit.add('file')
.commit('Initial commit')
.addRemote('origin', path.join(process.cwd(), 'tmp'), function() {
process.chdir('tmp');

return deploy({}).then(function() {
process.chdir('..');

return simpleGit.checkout('gh-pages').log(function(err, log) {
assert.equal(log.total, 1, '1 commit');
assert.equal(fs.readFileSync('tmp/file', 'utf8'), 'data');
finish();
});
}, function() {
process.chdir('..');
assert(false, 'Deploy\'s promise should be resolved');
}).catch(finish);
});
});
});
});

0 comments on commit a739d4f

Please sign in to comment.