diff --git a/test/integration/cnameExists.spec.js b/test/integration/cnameExists.spec.js new file mode 100644 index 00000000..33e57490 --- /dev/null +++ b/test/integration/cnameExists.spec.js @@ -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: 'user@email.com', + }, + cname: 'custom-domain.com', + }; + ghPages.publish(local, options, (err) => { + if (err) { + return done(err); + } + helper + .assertContentsMatch(expected, url, branch) + .then(() => done()) + .catch(done); + }); + }); + }); +}); diff --git a/test/integration/fixtures/cname-exists/expected/CNAME b/test/integration/fixtures/cname-exists/expected/CNAME new file mode 100644 index 00000000..5e5c92eb --- /dev/null +++ b/test/integration/fixtures/cname-exists/expected/CNAME @@ -0,0 +1 @@ +custom-domain.com diff --git a/test/integration/fixtures/cname-exists/expected/hello-world.txt b/test/integration/fixtures/cname-exists/expected/hello-world.txt new file mode 100644 index 00000000..980a0d5f --- /dev/null +++ b/test/integration/fixtures/cname-exists/expected/hello-world.txt @@ -0,0 +1 @@ +Hello World! diff --git a/test/integration/fixtures/cname-exists/local/hello-world.txt b/test/integration/fixtures/cname-exists/local/hello-world.txt new file mode 100644 index 00000000..980a0d5f --- /dev/null +++ b/test/integration/fixtures/cname-exists/local/hello-world.txt @@ -0,0 +1 @@ +Hello World! diff --git a/test/integration/fixtures/cname-exists/remote/CNAME b/test/integration/fixtures/cname-exists/remote/CNAME new file mode 100644 index 00000000..50c94db5 --- /dev/null +++ b/test/integration/fixtures/cname-exists/remote/CNAME @@ -0,0 +1 @@ +existing-domain.com diff --git a/test/integration/fixtures/cname-exists/remote/initial b/test/integration/fixtures/cname-exists/remote/initial new file mode 100644 index 00000000..e69de29b