Skip to content

Commit

Permalink
feat: pr review update test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiAlexandruParaschiv committed Aug 13, 2024
1 parent 6bfa5c4 commit 0248853
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/canonical/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ export async function canonicalAuditRunner(baseURL, context, site) {
}, {});

log.info(`Successfully completed Canonical Audit for site: ${baseURL}`);
log.info(`Audit results: ${JSON.stringify(aggregatedResults)}`);

return {
fullAuditRef: baseURL,
Expand Down
26 changes: 24 additions & 2 deletions test/audits/canonical.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,13 +523,35 @@ describe('Canonical URL Tests', () => {
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>`;
nock('http://example.com/page1').get('').reply(200, html);
const context = { log, dataAccess: { getTopPagesForSite: sinon.stub().resolves([{ getURL: () => 'http://example.com/page1' }]) } };

nock('http://example.com').get('/page1').reply(200, html);
nock(baseURL).get('/').reply(200, html);
const getTopPagesForSiteStub = sinon.stub().resolves([{ getURL: () => 'http://example.com/page1' }]);

const context = {
log,
dataAccess: {
getTopPagesForSite: getTopPagesForSiteStub,
},
};
const site = { getId: () => 'testSiteId' };

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

expect(result).to.be.an('object');
expect(result.auditResult).to.have.all.keys(
'canonical-self-referenced',
'canonical-tag-exists',
'canonical-tag-in-head',
'canonical-tag-nonempty',
'canonical-url-absolute',
'canonical-url-lowercased',
'canonical-url-same-domain',
'canonical-url-same-protocol',
'canonical-url-no-redirect',
'canonical-url-status-ok',
);
expect(getTopPagesForSiteStub).to.have.been.calledOnceWith('testSiteId', 'ahrefs', 'global');
expect(log.info).to.have.been.called;
});

Expand Down

0 comments on commit 0248853

Please sign in to comment.