|
1 | 1 | import { expect } from 'chai'; |
2 | 2 | import { spec } from 'modules/kargoBidAdapter.js'; |
3 | 3 | import { config } from 'src/config.js'; |
| 4 | +import { getStorageManager } from 'src/storageManager.js'; |
4 | 5 | const utils = require('src/utils'); |
| 6 | +const STORAGE = getStorageManager({bidderCode: 'kargo'}); |
5 | 7 |
|
6 | 8 | describe('kargo adapter tests', function() { |
7 | 9 | let bid, outstreamBid, testBids, sandbox, clock, frozenNow = new Date(), oldBidderSettings; |
@@ -1001,9 +1003,9 @@ describe('kargo adapter tests', function() { |
1001 | 1003 | }); |
1002 | 1004 |
|
1003 | 1005 | it('retrieves CRB from cookies if localstorage is not functional', function() { |
1004 | | - // Note: this does not cause localStorage to throw an error in Firefox so in that browser this |
1005 | | - // test is not 100% true to its name |
1006 | | - sandbox.stub(localStorage, 'getItem').throws(); |
| 1006 | + // Safari does not allow stubbing localStorage methods directly. |
| 1007 | + // Stub the storage manager instead so all browsers behave consistently. |
| 1008 | + sandbox.stub(STORAGE, 'getDataFromLocalStorage').throws(); |
1007 | 1009 | setCrb('valid', 'invalid'); |
1008 | 1010 |
|
1009 | 1011 | const payload = getPayloadFromTestBids(testBids, bidderRequest); |
@@ -1269,7 +1271,7 @@ describe('kargo adapter tests', function() { |
1269 | 1271 | }); |
1270 | 1272 |
|
1271 | 1273 | it('fails gracefully if there is no localStorage', function() { |
1272 | | - sandbox.stub(localStorage, 'getItem').throws(); |
| 1274 | + sandbox.stub(STORAGE, 'getDataFromLocalStorage').throws(); |
1273 | 1275 | let payload = getPayloadFromTestBids(testBids); |
1274 | 1276 | expect(payload.user).to.deep.equal({ |
1275 | 1277 | crbIDs: {}, |
@@ -1589,7 +1591,7 @@ describe('kargo adapter tests', function() { |
1589 | 1591 | }); |
1590 | 1592 |
|
1591 | 1593 | it('fails gracefully without localStorage', function() { |
1592 | | - sandbox.stub(localStorage, 'getItem').throws(); |
| 1594 | + sandbox.stub(STORAGE, 'getDataFromLocalStorage').throws(); |
1593 | 1595 | let payload = getPayloadFromTestBids(testBids); |
1594 | 1596 | expect(payload.page).to.be.undefined; |
1595 | 1597 | }); |
|
0 commit comments