diff --git a/src/legacyNativeRender.js b/src/legacyNativeRender.js index a1bba123..9d322ecd 100644 --- a/src/legacyNativeRender.js +++ b/src/legacyNativeRender.js @@ -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); diff --git a/test/spec/legacyNativeRender_spec.js b/test/spec/legacyNativeRender_spec.js new file mode 100644 index 00000000..106b4913 --- /dev/null +++ b/test/spec/legacyNativeRender_spec.js @@ -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(); + + }) +}) \ No newline at end of file diff --git a/test/spec/nativeRender_spec.js b/test/spec/nativeRender_spec.js new file mode 100644 index 00000000..23c56b2b --- /dev/null +++ b/test/spec/nativeRender_spec.js @@ -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(); + + }) +}) \ No newline at end of file