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:
Duke Greene 2023-08-02 07:01:25 -04:00 committed by GitHub
parent f0346d811f
commit 8eaab43ca4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View 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');
});
});

View file

@ -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 };