Skip to content

Commit

Permalink
fixes unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettBlox committed Oct 20, 2022
1 parent 19c0da3 commit b2e4255
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion modules/concertBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const spec = {

registerBidder(spec);

const storage = getStorageManager({bidderCode: BIDDER_CODE});
export const storage = getStorageManager({bidderCode: BIDDER_CODE});

/**
* Check or generate a UID for the current user.
Expand Down
24 changes: 11 additions & 13 deletions test/spec/modules/concertBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { spec } from 'modules/concertBidAdapter.js';
import { getStorageManager } from '../../../src/storageManager.js'
import { spec, storage } from 'modules/concertBidAdapter.js';
import { hook } from 'src/hook.js';

describe('ConcertAdapter', function () {
let bidRequests;
Expand All @@ -10,9 +10,8 @@ describe('ConcertAdapter', function () {
let element;
let sandbox;

afterEach(function () {
$$PREBID_GLOBAL$$.bidderSettings = {};
sandbox.restore();
before(function () {
hook.ready();
});

beforeEach(function () {
Expand All @@ -39,6 +38,7 @@ describe('ConcertAdapter', function () {
storageAllowed: true
}
};

bidRequests = [
{
bidder: 'concert',
Expand Down Expand Up @@ -83,6 +83,11 @@ describe('ConcertAdapter', function () {
sandbox.stub(document, 'getElementById').withArgs('desktop_leaderboard_variable').returns(element)
});

afterEach(function () {
$$PREBID_GLOBAL$$.bidderSettings = {};
sandbox.restore();
});

describe('spec.isBidRequestValid', function() {
it('should return when it recieved all the required params', function() {
const bid = bidRequests[0];
Expand Down Expand Up @@ -118,7 +123,6 @@ describe('ConcertAdapter', function () {
});

it('should not generate uid if the user has opted out', function() {
const storage = getStorageManager();
storage.setDataInLocalStorage('c_nap', 'true');
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
Expand All @@ -127,7 +131,6 @@ describe('ConcertAdapter', function () {
});

it('should generate uid if the user has not opted out', function() {
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
Expand All @@ -136,8 +139,8 @@ describe('ConcertAdapter', function () {
});

it('should grab uid from local storage if it exists', function() {
const storage = getStorageManager();
storage.setDataInLocalStorage('vmconcert_uid', 'foo');
console.log('GET', storage.getDataFromLocalStorage('vmconcert_uid'))
storage.removeDataFromLocalStorage('c_nap');
const request = spec.buildRequests(bidRequests, bidRequest);
const payload = JSON.parse(request.data);
Expand Down Expand Up @@ -211,7 +214,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.setDataInLocalStorage('c_nap', 'true');

const sync = spec.getUserSyncs(opts, [], bidRequest.gdprConsent, bidRequest.uspConsent);
Expand All @@ -222,7 +224,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand All @@ -237,7 +238,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand All @@ -252,7 +252,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand All @@ -268,7 +267,6 @@ describe('ConcertAdapter', function () {
const opts = {
iframeEnabled: true
};
const storage = getStorageManager();
storage.removeDataFromLocalStorage('c_nap');

bidRequest.gdprConsent = {
Expand Down

0 comments on commit b2e4255

Please sign in to comment.