2024-04-30 20:44:26 +02:00
|
|
|
import { matchNone } from '../js/query/boolean';
|
2024-05-01 00:20:14 +02:00
|
|
|
import '@testing-library/jest-dom/vitest';
|
2024-04-30 20:44:26 +02:00
|
|
|
import { URL } from 'node:url';
|
|
|
|
import { Blob } from 'node:buffer';
|
|
|
|
import { fireEvent } from '@testing-library/dom';
|
|
|
|
|
|
|
|
window.booru = {
|
|
|
|
timeAgo: () => {},
|
|
|
|
csrfToken: 'mockCsrfToken',
|
|
|
|
hiddenTag: '/mock-tagblocked.svg',
|
|
|
|
hiddenTagList: [],
|
2024-06-09 16:06:41 +02:00
|
|
|
hideStaffTools: 'true',
|
2024-04-30 20:44:26 +02:00
|
|
|
ignoredTagList: [],
|
|
|
|
imagesWithDownvotingDisabled: [],
|
|
|
|
spoilerType: 'off',
|
|
|
|
spoileredTagList: [],
|
|
|
|
userCanEditFilter: false,
|
|
|
|
userIsSignedIn: false,
|
|
|
|
watchedTagList: [],
|
|
|
|
hiddenFilter: matchNone(),
|
|
|
|
spoileredFilter: matchNone(),
|
|
|
|
interactions: [],
|
2024-06-05 22:56:48 +02:00
|
|
|
tagsVersion: 5,
|
2024-07-03 22:54:14 +02:00
|
|
|
galleryImages: [],
|
2024-04-30 20:44:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// https://github.com/jsdom/jsdom/issues/1721#issuecomment-1484202038
|
|
|
|
// jsdom URL and Blob are missing most of the implementation
|
|
|
|
// Use the node version of these types instead
|
|
|
|
Object.assign(globalThis, { URL, Blob });
|
|
|
|
|
|
|
|
// Prevents an error when calling `form.submit()` directly in
|
|
|
|
// the code that is being tested
|
2024-07-04 02:27:59 +02:00
|
|
|
HTMLFormElement.prototype.submit = function () {
|
2024-04-30 20:44:26 +02:00
|
|
|
fireEvent.submit(this);
|
|
|
|
};
|