From 4bcb7030aab165e85be11e9fb45916e9082ef3dd Mon Sep 17 00:00:00 2001 From: Tony Sullivan Date: Tue, 7 Jun 2022 15:32:54 -0500 Subject: [PATCH] test: matching a URL regex to ignore specific port numbers --- packages/astro/test/astro-global.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js index 6a295cfb1442..5a26270a0962 100644 --- a/packages/astro/test/astro-global.test.js +++ b/packages/astro/test/astro-global.test.js @@ -137,24 +137,24 @@ describe('Astro Global Defaults', () => { it('Astro.canonicalURL', async () => { // given a URL, expect the following canonical URL const canonicalURLs = { - '/index.html': 'http://localhost:3000/', - '/post/post/index.html': 'http://localhost:3000/post/post/', - '/posts/1/index.html': 'http://localhost:3000/posts/', - '/posts/2/index.html': 'http://localhost:3000/posts/2/', + '/index.html': /http:\/\/localhost:\d+\//, + '/post/post/index.html': /http:\/\/localhost:\d+\/post\/post\//, + '/posts/1/index.html': /http:\/\/localhost:\d+\/posts\//, + '/posts/2/index.html': /http:\/\/localhost:\d+\/posts\/2\//, }; for (const [url, canonicalURL] of Object.entries(canonicalURLs)) { const html = await fixture.readFile(url); const $ = cheerio.load(html); - expect($('link[rel="canonical"]').attr('href')).to.equal(canonicalURL); + expect($('link[rel="canonical"]').attr('href')).to.match(canonicalURL); } }); it('Astro.site', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('#site').attr('href')).to.equal('http://localhost:3000/'); + expect($('#site').attr('href')).to.match(/http:\/\/localhost:\d+\//); }); }); });