Skip to content

Commit

Permalink
feat: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiAlexandruParaschiv committed Aug 13, 2024
1 parent 0248853 commit 076f553
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions test/audits/canonical.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,10 @@ describe('Canonical URL Tests', () => {
const canonicalUrl = 'http://example.com/page1';
const redirectUrl = 'http://example.com/page2';

// Mock the initial request that returns a redirect
nock('http://example.com')
.get('/page1')
.reply(301, null, { Location: redirectUrl });

// Mock the redirected request that returns a 200 OK
nock('http://example.com')
.get('/page2')
.reply(200);
Expand Down Expand Up @@ -371,7 +369,6 @@ describe('Canonical URL Tests', () => {
success: true,
}]);

// Check that the result contains the "url-defined" check with failure
expect(result).to.deep.include.members([{
check: CANONICAL_CHECKS.URL_UNDEFINED.check,
success: false,
Expand Down Expand Up @@ -490,7 +487,7 @@ describe('Canonical URL Tests', () => {

const result = await validateCanonicalTag(url, log);

// Ensure that the resolved canonical URL is correct
// ensure that the resolved canonical URL is correct
expect(result.canonicalUrl).to.equal(expectedCanonicalUrl);
expect(result.checks).to.deep.include({
check: CANONICAL_CHECKS.CANONICAL_TAG_NONEMPTY.check,
Expand Down Expand Up @@ -585,7 +582,7 @@ describe('Canonical URL Tests', () => {

const result = await canonicalAuditRunner(baseURL, context, site);

// Verify that the returned audit result indicates a failure with the correct error message
// verify that the returned audit result indicates a failure with an error message
expect(result).to.deep.equal({
fullAuditRef: baseURL,
auditResult: {
Expand All @@ -594,24 +591,5 @@ describe('Canonical URL Tests', () => {
},
});
});

it('should pass if the canonical URL points to itself', async () => {
const url = 'http://example.com';
const html = `<html><head><link rel="canonical" href="${url}"></head><body></body></html>`;
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);

expect(result.checks).to.deep.include.members([
{
check: 'canonical-tag-nonempty',
success: true,
},
{
check: 'canonical-tag-exists',
success: true,
}]);
expect(log.info).to.have.been.calledWith(`Canonical URL ${url} references itself`);
});
});
});

0 comments on commit 076f553

Please sign in to comment.