From b6b84541cb7918ce1b99ea9688808f63af0c356a Mon Sep 17 00:00:00 2001 From: WillBAnders Date: Wed, 20 Dec 2023 22:25:57 -0500 Subject: [PATCH] Add test for cnameExists, asserting it replaces the existing CNAME --- test/integration/cnameExists.spec.js | 38 +++++++++++++++++++ .../fixtures/cname-exists/expected/CNAME | 1 + .../cname-exists/expected/hello-world.txt | 1 + .../cname-exists/local/hello-world.txt | 1 + .../fixtures/cname-exists/remote/CNAME | 1 + .../fixtures/cname-exists/remote/initial | 0 6 files changed, 42 insertions(+) create mode 100644 test/integration/cnameExists.spec.js create mode 100644 test/integration/fixtures/cname-exists/expected/CNAME create mode 100644 test/integration/fixtures/cname-exists/expected/hello-world.txt create mode 100644 test/integration/fixtures/cname-exists/local/hello-world.txt create mode 100644 test/integration/fixtures/cname-exists/remote/CNAME create mode 100644 test/integration/fixtures/cname-exists/remote/initial 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