mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 23:08:00 +01:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
|
import { matchNone } from '../js/query/boolean';
|
||
|
import chai from 'chai';
|
||
|
import chaiDom from 'chai-dom';
|
||
|
import { URL } from 'node:url';
|
||
|
import { Blob } from 'node:buffer';
|
||
|
import { fireEvent } from '@testing-library/dom';
|
||
|
|
||
|
chai.use(chaiDom);
|
||
|
|
||
|
window.booru = {
|
||
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||
|
timeAgo: () => {},
|
||
|
csrfToken: 'mockCsrfToken',
|
||
|
hiddenTag: '/mock-tagblocked.svg',
|
||
|
hiddenTagList: [],
|
||
|
ignoredTagList: [],
|
||
|
imagesWithDownvotingDisabled: [],
|
||
|
spoilerType: 'off',
|
||
|
spoileredTagList: [],
|
||
|
userCanEditFilter: false,
|
||
|
userIsSignedIn: false,
|
||
|
watchedTagList: [],
|
||
|
hiddenFilter: matchNone(),
|
||
|
spoileredFilter: matchNone(),
|
||
|
interactions: [],
|
||
|
tagsVersion: 5
|
||
|
};
|
||
|
|
||
|
// 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
|
||
|
HTMLFormElement.prototype.submit = function() {
|
||
|
fireEvent.submit(this);
|
||
|
};
|