docbrown/app/javascript/__tests__/billboard.test.js
Joshua Wehner 6fe9d7d7a6
Allow org admins to add members as co-authors (#20008)
* Basics might be working?

* Stop propagating button clicks in autocomplete pills

* Better blank slate

* Better location to stop propagation

* Remove author_id from org co-authors

* Move UserStore and try testing it

* Remove extraneous comments

* OH... that's what that does!

* Very basic testing

* Re-organize javascripts

* Rename & re-org for testing

* Cleanup

* More tests

* Remove unnecessary nesting

* Coninuing to try to bump coverage

* Include /packs/ in code coverage metric

* Try tweaking jest coverage more?

We probably can't collect coverage from all of packs/* (because coverage is too low) but maybe we can try to opt-in for newer areas as we go?

* Relocate JS tests, for build & coverage

* User ID exception on search, not fetch

* Remove commented-out console.log

---------

Co-authored-by: Mac Siri <krairit.siri@gmail.com>
2023-09-15 08:12:41 -04:00

23 lines
777 B
JavaScript

import { getBillboard } from '../packs/billboard';
describe('getBillboard', () => {
beforeEach(() => {
global.Honeybadger = { notify: jest.fn() };
document.body.innerHTML = `
<div>
<div class="js-billboard-container" data-async-url="/billboards/sidebar_left"></div>
<div class="js-billboard-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');
});
});