docbrown/app/javascript/utilities/http/__tests__/csrfToken.test.js
Ridhwana 3f9b7c073c
Add a MultiSelect Autocomplete component to the Display Ads Page (#18560)
* feat: Add a pack file that pulls in the MultiSelect Component

* feat: move the tags to its own component

* save tags

* refactor: create a getCSRFToken function in the packs files so that it can be used in the admin

* feat: import the new module in request.js

* feat: remove unnecessary id

* feat: first pass of csrf token test

* chore: update the test

* fix: csrf token

* feat: hide the enw functionality behinda  feature flag

* fix: loading form twice

* refactor: import for csrftoken
2022-10-26 16:24:31 +02:00

14 lines
574 B
JavaScript

import { getCSRFToken } from '@utilities/http/csrfToken';
describe('getCSRFToken', () => {
it('should resolve with the CSRF token when there is a meta tag', async () => {
document.head.innerHTML = `<meta name="csrf-token" content="this-is-a-csrf-token"></head>`;
const data = await getCSRFToken();
expect(data).toBe('this-is-a-csrf-token');
});
// [@ridhwana] It was proving to be really difficult to test the error case
// since there are timers and max retries on setInterval, and I was
// struggling to achieve the scenario with jest timers.
});