UNPKG

1.48 kBJavaScriptView Raw
1var fs = require('fs');
2var path = require('path');
3
4var helper = require('./helper');
5
6var assert = helper.assert;
7
8describe('unpushed', function() {
9 var fixture, repo;
10
11 before(function(done) {
12 this.timeout(3000);
13 helper.buildFixture('unpushed', function(error, dir) {
14 fixture = dir;
15 repo = path.join(fixture, '.grunt/grunt-gh-pages/gh-pages/src');
16 done(error);
17 });
18 });
19
20 after(function(done) {
21 helper.afterFixture(fixture, done);
22 });
23
24 it('creates .grunt/grunt-gh-pages/gh-pages/src directory', function(done) {
25 fs.stat(repo, function(error, stats) {
26 assert.isTrue(!error, 'no error');
27 assert.isTrue(stats.isDirectory(), 'directory');
28 done(error);
29 });
30 });
31
32 it('creates a gh-pages branch', function(done) {
33 var branch;
34 helper.git(['rev-parse', '--abbrev-ref', 'HEAD'], repo)
35 .progress(function(chunk) {
36 branch = String(chunk);
37 })
38 .then(function() {
39 assert.strictEqual(branch, 'gh-pages\n', 'branch created');
40 done();
41 })
42 .fail(done);
43 });
44
45 it('does not push the gh-pages branch to remote', function(done) {
46 helper.git(['ls-remote', '--exit-code', '.', 'origin/gh-pages'], repo)
47 .then(function() {
48 done(new Error('Expected not to find origin/gh-pages'));
49 })
50 .fail(function() {
51 // failure on the ls-remote is what we're looking for (no push)
52 done();
53 });
54 });
55
56});