Skip to content

Commit

Permalink
Add options.remove tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghwan2789 committed Feb 26, 2020
1 parent 66f3ddb commit 878fe5c
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/integration/fixtures/remove/expected/new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// to be copied
1 change: 1 addition & 0 deletions test/integration/fixtures/remove/expected/stable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file should not be removed.
1 change: 1 addition & 0 deletions test/integration/fixtures/remove/local/new.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// to be copied
1 change: 1 addition & 0 deletions test/integration/fixtures/remove/remote/removed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* to be removed */
1 change: 1 addition & 0 deletions test/integration/fixtures/remove/remote/removed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// to be removed
1 change: 1 addition & 0 deletions test/integration/fixtures/remove/remote/stable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file should not be removed.
67 changes: 67 additions & 0 deletions test/integration/remove.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
});
});
});
});

0 comments on commit 878fe5c

Please sign in to comment.