Skip to content

Commit 59a15ba

Browse files
committed
Adriver ID system: fix spurious test failure
Fix Adriver ID system test failures (https://app.circleci.com/pipelines/github/prebid/Prebid.js/13137/workflows/5e686ed9-e57e-47b3-9c4e-8beea10be321/jobs/24200). This was already done in prebid#8489, but prebid#8768 undid it.
1 parent 918ffb9 commit 59a15ba

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/spec/modules/adriverIdSystem_spec.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ describe('AdriverIdSystem', function () {
6666
let request = server.requests[0];
6767
request.respond(200, { 'Content-Type': 'application/json' }, JSON.stringify({ adrcid: response.adrcid }));
6868

69-
let now = new Date();
70-
now.setTime(now.getTime() + 86400 * 1825 * 1000);
69+
let expectedExpiration = new Date();
70+
expectedExpiration.setTime(expectedExpiration.getTime() + 86400 * 1825 * 1000);
7171
const minimalDate = new Date(0).toString();
7272

73+
function dateStringFor(date, maxDeltaMs = 2000) {
74+
return sinon.match((val) => Math.abs(date.getTime() - new Date(val).getTime()) <= maxDeltaMs)
75+
}
76+
7377
if (response.adrcid) {
74-
expect(setCookieStub.calledWith('adrcid', response.adrcid, now.toUTCString())).to.be.true;
78+
expect(setCookieStub.calledWith('adrcid', response.adrcid, dateStringFor(expectedExpiration))).to.be.true;
7579
expect(setLocalStorageStub.calledWith('adrcid', response.adrcid)).to.be.true;
7680
} else {
7781
expect(setCookieStub.calledWith('adrcid', '', minimalDate)).to.be.false;

0 commit comments

Comments
 (0)