This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for 'deploy'. Fixes #34
- Loading branch information
Marco Castelluccio
committed
Oct 12, 2015
1 parent
6ad1ad2
commit a739d4f
Showing
2 changed files
with
44 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,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); | ||
}); | ||
}); | ||
}); | ||
}); |