Skip to content

Commit

Permalink
Update stubs to new sinon stub syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlane committed Sep 5, 2017
1 parent 84b17d3 commit 7774e78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
4 changes: 1 addition & 3 deletions test/spec/bidmanager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ describe('bidmanager.js', function () {
});

it('requires a renderer on outstream bids', () => {
sinon.stub(utils, 'getBidRequest', () => ({
getSandbox().stub(utils, 'getBidRequest').callsFake(() => ({
bidder: 'appnexusAst',
mediaTypes: {
video: {context: 'outstream'}
Expand All @@ -618,8 +618,6 @@ describe('bidmanager.js', function () {
const bidsRecCount = $$PREBID_GLOBAL$$._bidsReceived.length;
bidmanager.addBidResponse('adUnit-code', bid);
assert.equal(bidsRecCount + 1, $$PREBID_GLOBAL$$._bidsReceived.length);

utils.getBidRequest.restore();
});
});
});
26 changes: 11 additions & 15 deletions test/spec/video_spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import useSandbox from 'test/mocks/sandbox';
import { isValidVideoBid } from 'src/video';
const utils = require('src/utils');

describe('video.js', () => {
const getSandbox = useSandbox()

it('validates valid instream bids', () => {
sinon.stub(utils, 'getBidRequest', () => ({
getSandbox().stub(utils, 'getBidRequest').callsFake(() => ({
bidder: 'appnexusAst',
mediaTypes: {
video: { context: 'instream' },
Expand All @@ -15,12 +18,10 @@ describe('video.js', () => {
});

expect(valid).to.be(true);

utils.getBidRequest.restore();
});

it('catches invalid instream bids', () => {
sinon.stub(utils, 'getBidRequest', () => ({
getSandbox().stub(utils, 'getBidRequest').callsFake(() => ({
bidder: 'appnexusAst',
mediaTypes: {
video: { context: 'instream' },
Expand All @@ -30,31 +31,28 @@ describe('video.js', () => {
const valid = isValidVideoBid({});

expect(valid).to.be(false);

utils.getBidRequest.restore();
});

it('validates valid outstream bids', () => {
sinon.stub(utils, 'getBidRequest', () => ({
getSandbox().stub(utils, 'getBidRequest').callsFake(() => ({
bidder: 'appnexusAst',
mediaTypes: {
video: { context: 'outstream' },
},
}));

const valid = isValidVideoBid({
renderer: {
url: 'render.url',
render: () => true,
}
}));

const valid = isValidVideoBid({});
});

expect(valid).to.be(true);

utils.getBidRequest.restore();
});

it('catches invalid outstream bids', () => {
sinon.stub(utils, 'getBidRequest', () => ({
getSandbox().stub(utils, 'getBidRequest').callsFake(() => ({
bidder: 'appnexusAst',
mediaTypes: {
video: { context: 'outstream' },
Expand All @@ -64,7 +62,5 @@ describe('video.js', () => {
const valid = isValidVideoBid({});

expect(valid).to.be(false);

utils.getBidRequest.restore();
});
});

0 comments on commit 7774e78

Please sign in to comment.