Skip to content

Commit

Permalink
fix: ready to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiAlexandruParaschiv committed Aug 23, 2024
1 parent 329f06b commit 8b1979f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/audits/canonical.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Canonical URL Tests', () => {
describe('validateCanonicalTag', () => {
it('should handle missing canonical tag', async () => {
const url = 'http://example.com';
const html = '<!DOCTYPE html><html><head></head><body></body></html>';
const html = '<!DOCTYPE html><html lang="en"><head><title>test</title></head><body></body></html>';
nock('http://example.com').get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('Canonical URL Tests', () => {

it('should handle invalid canonical URL correctly', async () => {
const url = 'http://example.com';
const html = '<html><head><link rel="canonical" href="invalid-url"></head><body></body></html>';
const html = '<html lang="en"><head><link rel="canonical" href="invalid-url"><title>test</title></head><body></body></html>';
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand All @@ -168,7 +168,7 @@ describe('Canonical URL Tests', () => {

it('should handle empty canonical tag', async () => {
const url = 'http://example.com';
const html = '<html><head><link rel="canonical" href=""></head><body></body></html>';
const html = '<html lang="en"><head><link rel="canonical" href=""><title>test</title></head><body></body></html>';
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand All @@ -184,7 +184,7 @@ describe('Canonical URL Tests', () => {

it('should handle multiple canonical tags', async () => {
const url = 'http://example.com';
const html = '<html><head><link rel="canonical" href="http://example.com/page1"><link rel="canonical" href="http://example.com/page2"></head><body></body></html>';
const html = '<html lang="en"><head><link rel="canonical" href="http://example.com/page1"><link rel="canonical" href="http://example.com/page2"><title>test</title></head><body></body></html>';
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand All @@ -198,7 +198,7 @@ describe('Canonical URL Tests', () => {

it('should fail if the canonical tag is not in the head section', async () => {
const url = 'http://example.com';
const html = '<html><head></head><body><link rel="canonical" href="http://example.com"></body></html>';
const html = '<html lang="en"><head><title>test</title></head><body><link rel="canonical" href="http://example.com"></body></html>';
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand Down Expand Up @@ -356,7 +356,7 @@ 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>`;
const html = `<html lang="en"><head><link rel="canonical" href="${url}"><title>test</title></head><body></body></html>`;
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand Down Expand Up @@ -396,7 +396,7 @@ describe('Canonical URL Tests', () => {
it('should fail if the canonical URL does not point to itself', async () => {
const url = 'http://example.com';
const canonicalUrl = 'http://example.com/other-page';
const html = `<html><head><link rel="canonical" href="${canonicalUrl}"></head><body></body></html>`;
const html = `<html lang="en"><head><link rel="canonical" href="${canonicalUrl}"><title>test</title></head><body></body></html>`;
nock(url).get('/').reply(200, html);

const result = await validateCanonicalTag(url, log);
Expand Down Expand Up @@ -486,9 +486,9 @@ describe('Canonical URL Tests', () => {
const expectedCanonicalUrl = 'https://example.com/canonical-page';

const html = `
<html>
<html lang="en">
<head>
<link rel="canonical" href="${href}">
<link rel="canonical" href="${href}"><title>test</title>
</head>
<body>
<h1>Test Page</h1>
Expand Down Expand Up @@ -534,7 +534,7 @@ describe('Canonical URL Tests', () => {
describe('canonicalAuditRunner', () => {
it('should run canonical audit successfully', async () => {
const baseURL = 'http://example.com';
const html = `<html><head><link rel="canonical" href="${baseURL}"></head><body></body></html>`;
const html = `<html lang="en"><head><link rel="canonical" href="${baseURL}"><title>test</title></head><body></body></html>`;

nock('http://example.com').get('/page1').reply(200, html);
nock(baseURL).get('/').reply(200, html);
Expand Down

0 comments on commit 8b1979f

Please sign in to comment.