Skip to content

Commit

Permalink
implement find polyfill in unit test (prebid#3156)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored Oct 4, 2018
1 parent c3f9107 commit 3ba867a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as ajaxLib from 'src/ajax';
import * as auctionModule from 'src/auction';
import { newBidder, registerBidder } from 'src/adapters/bidderFactory';
import * as targetingModule from 'src/targeting';
import find from 'core-js/library/fn/array/find';

var assert = require('chai').assert;
var expect = require('chai').expect;
Expand Down Expand Up @@ -1849,9 +1850,8 @@ describe('Unit: Prebid Module', function () {
// mark the bid and verify the state has changed to RENDERED
const winningBid = targeting.getWinningBids(adUnitCode)[0];
$$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode, adId: winningBid.adId });
const markedBid = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode)
.bids
.find(bid => bid.adId === winningBid.adId);
const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids,
bid => bid.adId === winningBid.adId);

expect(markedBid.status).to.equal(RENDERED);
resetAuction();
Expand All @@ -1864,9 +1864,8 @@ describe('Unit: Prebid Module', function () {

const winningBid = targeting.getWinningBids(adUnitCode)[0];
$$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode, adId: 'miss' });
const markedBid = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode)
.bids
.find(bid => bid.adId === winningBid.adId);
const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids,
bid => bid.adId === winningBid.adId);

expect(markedBid.status).to.not.equal(RENDERED);
resetAuction();
Expand All @@ -1881,9 +1880,8 @@ describe('Unit: Prebid Module', function () {
// mark the bid and verify the state has changed to RENDERED
const winningBid = targeting.getWinningBids(adUnitCode)[0];
$$PREBID_GLOBAL$$.markWinningBidAsUsed({ adUnitCode });
const markedBid = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode)
.bids
.find(bid => bid.adId === winningBid.adId);
const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids,
bid => bid.adId === winningBid.adId);

expect(markedBid.status).to.equal(RENDERED);
resetAuction();
Expand All @@ -1898,9 +1896,8 @@ describe('Unit: Prebid Module', function () {
// mark the bid and verify the state has changed to RENDERED
const winningBid = targeting.getWinningBids(adUnitCode)[0];
$$PREBID_GLOBAL$$.markWinningBidAsUsed({ adId: winningBid.adId });
const markedBid = $$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode)
.bids
.find(bid => bid.adId === winningBid.adId);
const markedBid = find($$PREBID_GLOBAL$$.getBidResponsesForAdUnitCode(adUnitCode).bids,
bid => bid.adId === winningBid.adId);

expect(markedBid.status).to.equal(RENDERED);
resetAuction();
Expand Down

0 comments on commit 3ba867a

Please sign in to comment.