Skip to content

Commit

Permalink
add test for legacyNativeRender to accept only one argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Nasti committed Sep 22, 2022
1 parent 1b06763 commit f1e96b0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/legacyNativeRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import { newNativeRenderManager } from './nativeRenderManager';
window.pbNativeTag = (window.pbNativeTag || {});
const nativeRenderManager = newNativeRenderManager(window);

window.pbNativeTag.renderNativeAd = nativeRenderManager.renderNativeAd;
window.pbNativeTag.renderNativeAd = (args) => nativeRenderManager.renderNativeAd.call(document, args);
21 changes: 21 additions & 0 deletions test/spec/legacyNativeRender_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '../../src/legacyNativeRender';

describe('legacyNativeRender', () => {

after(() => {
delete window.pbNativeTag;
})
it('should accept only one argument', () => {
expect(window.pbNativeTag.renderNativeAd).to.exist;
//expect exactly one argument by this function
expect(window.pbNativeTag.renderNativeAd.length).to.equal(1);

// try to call this function with two arguments and see it throw
const renderNativeAdWithTwoArguments = window.pbNativeTag.renderNativeAd.bind(this, document, {
pubUrl: 'http://prebidjs.com',
adId: 'abc123'
})
expect(renderNativeAdWithTwoArguments).to.throw();

})
})
23 changes: 23 additions & 0 deletions test/spec/nativeRender_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../../src/nativeRender';

describe('nativeRender', () => {

after(() => {
delete window.ucTag;
})

it('should accept 2 arguments', () => {
expect(window.ucTag.renderAd).to.exist;
//expect exactly two arguments by this function
expect(window.ucTag.renderAd.length).to.equal(2);

// this function with two arguments and see it NOT throwing
const renderAd = window.ucTag.renderAd.bind(this, document, {
pubUrl: 'http://prebidjs.com',
adId: 'abc123',
replaceAllAssets: true
})
expect(renderAd).to.not.throw();

})
})

0 comments on commit f1e96b0

Please sign in to comment.