Skip to content

Commit

Permalink
Add tests for catch case when cross-origin
Browse files Browse the repository at this point in the history
  • Loading branch information
github-mickael-leclerc committed Sep 6, 2023
1 parent 087eaa7 commit ae1deb9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/spec/modules/teadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ describe('teadsBidAdapter', () => {
expect(payload.pageTitle).to.exist;
expect(payload.pageTitle).to.have.length(300);
});

it('should add pageTitle info to payload when fallbacking from window.top', function () {
const testText = 'This is a fallback title';
sandbox.stub(window.top.document, 'querySelector').throws();
sandbox.stub(document, 'title').value(testText);

const request = spec.buildRequests(bidRequests, bidderRequestDefault);
const payload = JSON.parse(request.data);

expect(payload.pageTitle).to.exist;
expect(payload.pageTitle).to.deep.equal(testText);
});
});

describe('pageDescription', function () {
Expand Down Expand Up @@ -323,6 +335,18 @@ describe('teadsBidAdapter', () => {
expect(payload.pageDescription).to.exist;
expect(payload.pageDescription).to.have.length(300);
});

it('should add pageDescription info to payload when fallbacking from window.top', function () {
const testText = 'This is a fallback description from open-graph';
sandbox.stub(window.top.document, 'querySelector').throws();
sandbox.stub(document, 'querySelector').withArgs('meta[name="description"]').returns({ content: testText });

const request = spec.buildRequests(bidRequests, bidderRequestDefault);
const payload = JSON.parse(request.data);

expect(payload.pageDescription).to.exist;
expect(payload.pageDescription).to.deep.equal(testText);
});
});

it('should add timeToFirstByte info to payload', function () {
Expand Down

0 comments on commit ae1deb9

Please sign in to comment.