forked from tschaub/gh-pages
/
remove.spec.js
67 lines (59 loc) · 1.64 KB
/
remove.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const helper = require('../helper');
const ghPages = require('../../lib/');
const path = require('path');
const fixtures = path.join(__dirname, 'fixtures');
const fixtureName = 'remove';
beforeEach(() => {
ghPages.clean();
});
describe('the remove option', () => {
it('removes matched files in remote branch', done => {
const local = path.join(fixtures, fixtureName, 'local');
const expected = path.join(fixtures, fixtureName, 'expected');
const branch = 'gh-pages';
const remove = '*.{js,css}';
helper.setupRemote(fixtureName, {branch}).then(url => {
const options = {
repo: url,
user: {
name: 'User Name',
email: 'user@email.com'
},
remove: remove
};
ghPages.publish(local, options, err => {
if (err) {
return done(err);
}
helper
.assertContentsMatch(expected, url, branch)
.then(() => done())
.catch(done);
});
});
});
it('skips removing files if there are no files to be removed', done => {
const local = path.join(fixtures, fixtureName, 'remote');
const branch = 'gh-pages';
const remove = 'non-exist-file';
helper.setupRemote(fixtureName, {branch}).then(url => {
const options = {
repo: url,
user: {
name: 'User Name',
email: 'user@email.com'
},
remove: remove
};
ghPages.publish(local, options, err => {
if (err) {
return done(err);
}
helper
.assertContentsMatch(local, url, branch)
.then(() => done())
.catch(done);
});
});
});
});