1 | var fs = require('fs');
|
2 | var path = require('path');
|
3 |
|
4 | var helper = require('./helper');
|
5 |
|
6 | var assert = helper.assert;
|
7 |
|
8 | describe('deep-base', function() {
|
9 | var fixture, repo;
|
10 |
|
11 | before(function(done) {
|
12 | this.timeout(3000);
|
13 | helper.buildFixture('deep-base', 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('copies source files relative to the base', function(done) {
|
46 | fs.exists(path.join(repo, 'hello.txt'), function(exists) {
|
47 | if (!exists) {
|
48 | done(new Error('Failed to find "hello.txt" in repo: ') + repo);
|
49 | } else {
|
50 | done();
|
51 | }
|
52 | });
|
53 | });
|
54 |
|
55 | it('pushes the gh-pages branch to remote', function(done) {
|
56 | helper.git(['ls-remote', '--exit-code', '.', 'origin/gh-pages'], repo)
|
57 | .then(function() {
|
58 | done();
|
59 | })
|
60 | .fail(done);
|
61 | });
|
62 |
|
63 | });
|