/
beforeAdd.spec.js
41 lines (37 loc) · 1.05 KB
/
beforeAdd.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
const helper = require('../helper');
const ghPages = require('../../lib/');
const path = require('path');
const fixtures = path.join(__dirname, 'fixtures');
const fixtureName = 'beforeAdd';
beforeEach(() => {
ghPages.clean();
});
describe('the beforeAdd option', () => {
it('runs a provided async function before adding files', done => {
const local = path.join(fixtures, fixtureName, 'local');
const expected = path.join(fixtures, fixtureName, 'expected');
const branch = 'gh-pages';
helper.setupRemote(fixtureName, {branch}).then(url => {
const options = {
repo: url,
add: true,
async beforeAdd(git) {
return git.rm('hello-outdated-world.txt');
},
user: {
name: 'User Name',
email: 'user@email.com'
}
};
ghPages.publish(local, options, err => {
if (err) {
return done(err);
}
helper
.assertContentsMatch(expected, url, branch)
.then(() => done())
.catch(done);
});
});
});
});