Skip to content

Commit

Permalink
fix: simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiAlexandruParaschiv committed Aug 23, 2024
1 parent 61cb387 commit 533b858
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions test/audits/canonical.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,25 +325,19 @@ describe('Canonical URL Tests', () => {
expect(log.info).to.have.been.calledWith('Canonical URL https://example.com uses a different protocol than base URL http://example.com');
});

it('should pass when canonical URL and base URL are identical, including the www prefix', () => {
const canonicalUrl = 'https://www.example.com';
const baseUrl = 'https://example.com';
const result = validateCanonicalFormat(canonicalUrl, baseUrl, log);

expect(result).to.deep.include({
check: 'canonical-url-same-domain',
success: true,
});
});
it('should pass when canonical URL and base URL are identical, regardless of the www prefix', () => {
const cases = [
{ canonicalUrl: 'https://www.example.com', baseUrl: 'https://example.com' },
{ canonicalUrl: 'https://example.com', baseUrl: 'https://www.example.com' },
];

it('should pass when canonical URL and base URL are identical, including the www prefix', () => {
const canonicalUrl = 'https://example.com';
const baseUrl = 'https://www.example.com';
const result = validateCanonicalFormat(canonicalUrl, baseUrl, log);
cases.forEach(({ canonicalUrl, baseUrl }) => {
const result = validateCanonicalFormat(canonicalUrl, baseUrl, log);

expect(result).to.deep.include({
check: 'canonical-url-same-domain',
success: true,
expect(result).to.deep.include({
check: 'canonical-url-same-domain',
success: true,
});
});
});

Expand Down

0 comments on commit 533b858

Please sign in to comment.