Skip to content

Commit

Permalink
Add test for cnameExists, asserting it replaces the existing CNAME
Browse files Browse the repository at this point in the history
  • Loading branch information
WillBAnders committed Dec 21, 2023
1 parent 1c60556 commit b6b8454
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/integration/cnameExists.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const helper = require('../helper.js');
const ghPages = require('../../lib/index.js');
const path = require('path');

const fixtures = path.join(__dirname, 'fixtures');
const fixtureName = 'cname-exists';

beforeEach(() => {
ghPages.clean();
});

describe('the --cname option', () => {
it('works even if the CNAME file already exists AND replaces any existing value', (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,
user: {
name: 'User Name',
email: '[email protected]',
},
cname: 'custom-domain.com',
};
ghPages.publish(local, options, (err) => {
if (err) {
return done(err);
}
helper
.assertContentsMatch(expected, url, branch)
.then(() => done())
.catch(done);
});
});
});
});
1 change: 1 addition & 0 deletions test/integration/fixtures/cname-exists/expected/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom-domain.com
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
1 change: 1 addition & 0 deletions test/integration/fixtures/cname-exists/remote/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
existing-domain.com
Empty file.

0 comments on commit b6b8454

Please sign in to comment.