add simple spec for billboard placement, use imported observe function (#19836)
* add simple spec for billboard placement, use imported observe function * change import location and avoid exporting from the assets folder
This commit is contained in:
parent
f0346d811f
commit
8eaab43ca4
2 changed files with 26 additions and 0 deletions
23
app/javascript/packs/__tests__/billboard.test.js
Normal file
23
app/javascript/packs/__tests__/billboard.test.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { getBillboard } from '../billboard';
|
||||
|
||||
describe('getBillboard', () => {
|
||||
beforeEach(() => {
|
||||
global.Honeybadger = { notify: jest.fn() };
|
||||
document.body.innerHTML = `
|
||||
<div>
|
||||
<div class="js-display-ad-container" data-async-url="/billboards/sidebar_left"></div>
|
||||
<div class="js-display-ad-container" data-async-url="/billboards/sidebar_left_2"></div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
|
@ -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 };
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue