Skip to content

Commit

Permalink
fix: improve tests to use MockContextBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
dzehnder committed Aug 20, 2024
1 parent 9bc2596 commit db65fad
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/audits/pdp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ import sinonChai from 'sinon-chai';
import sinon from 'sinon';

import { gscPdpStructuredDataHandler } from '../../src/url-inspect/pdp-handler.js';
import { MockContextBuilder } from '../shared.js';

use(sinonChai);

const sandbox = sinon.createSandbox();
const message = {
type: 'gsc-pdp-structured-data',
url: 'https://www.example.com',
};

describe('URLInspect Audit', () => {
let context;
Expand All @@ -31,13 +36,16 @@ describe('URLInspect Audit', () => {
let fullUrlInspectionResult;

beforeEach(() => {
context = {
log: {
info: sinon.stub(),
warn: sinon.stub(),
error: sinon.stub(),
},
};
context = new MockContextBuilder()
.withSandbox(sandbox)
.withOverrides({
log: {
info: sinon.stub(),
warn: sinon.stub(),
error: sinon.stub(),
},
})
.build(message);

googleClientStub = {
urlInspect: sandbox.stub(),
Expand Down

0 comments on commit db65fad

Please sign in to comment.