diff --git a/app/javascript/packs/__tests__/billboard.test.js b/app/javascript/packs/__tests__/billboard.test.js new file mode 100644 index 000000000..1a77b5a6a --- /dev/null +++ b/app/javascript/packs/__tests__/billboard.test.js @@ -0,0 +1,23 @@ +import { getBillboard } from '../billboard'; + +describe('getBillboard', () => { + beforeEach(() => { + global.Honeybadger = { notify: jest.fn() }; + document.body.innerHTML = ` +
+
+
+
+ `; + }); + + test('should make a call to the correct placement url', async () => { + const fetchPromise = Promise.resolve('fetch response'); + window.fetch = jest.fn(fetchPromise); + + await getBillboard(); + + expect(window.fetch).toHaveBeenCalledWith('/billboards/sidebar_left'); + expect(window.fetch).toHaveBeenCalledWith('/billboards/sidebar_left_2'); + }); +}); diff --git a/app/javascript/packs/billboard.js b/app/javascript/packs/billboard.js index c120fe749..917902eec 100644 --- a/app/javascript/packs/billboard.js +++ b/app/javascript/packs/billboard.js @@ -1,4 +1,5 @@ import { setupDisplayAdDropdown } from '../utilities/displayAdDropdown'; +import { observeDisplayAds } from './billboardAfterRenderActions'; // the term billboard can be synonymously interchanged with displayAd async function getBillboard() { @@ -38,3 +39,5 @@ async function generateDisplayAd(element) { } getBillboard(); + +export { getBillboard };