mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
Mock range api globally
This commit is contained in:
parent
67750e0f82
commit
5a5a2666b1
@ -46,6 +46,7 @@ module.exports = {
|
||||
'<rootDir>/packages/admin-test-utils/lib/mocks/IntersectionObserver.js',
|
||||
'<rootDir>/packages/admin-test-utils/lib/mocks/ResizeObserver.js',
|
||||
'<rootDir>/packages/admin-test-utils/lib/mocks/windowMatchMedia.js',
|
||||
'<rootDir>/packages/admin-test-utils/lib/mocks/mockRangeApi.js',
|
||||
],
|
||||
setupFilesAfterEnv: [
|
||||
'<rootDir>/packages/admin-test-utils/lib/setup/styled-components.js',
|
||||
|
||||
16
packages/admin-test-utils/lib/mocks/mockRangeApi.js
Normal file
16
packages/admin-test-utils/lib/mocks/mockRangeApi.js
Normal file
@ -0,0 +1,16 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
'use strict';
|
||||
|
||||
// Codemirror inner dependency, reference: https://github.com/jsdom/jsdom/issues/3002
|
||||
// Otherwise it throws: TypeError: range(...).getBoundingClientRect is not a function
|
||||
|
||||
document.createRange = () => {
|
||||
const range = new Range();
|
||||
range.getClientRects = jest.fn(() => ({
|
||||
item: () => null,
|
||||
length: 0,
|
||||
}));
|
||||
|
||||
return range;
|
||||
};
|
||||
@ -16,18 +16,6 @@ const user = userEvent.setup();
|
||||
|
||||
jest.mock('../hooks/useAuditLogsData', () => jest.fn());
|
||||
|
||||
// Codemirror inner dependency, reference: https://github.com/jsdom/jsdom/issues/3002
|
||||
// Otherwise it throws: TypeError: range(...).getBoundingClientRect is not a function
|
||||
document.createRange = () => {
|
||||
const range = new Range();
|
||||
range.getClientRects = jest.fn(() => ({
|
||||
item: () => null,
|
||||
length: 0,
|
||||
}));
|
||||
|
||||
return range;
|
||||
};
|
||||
|
||||
const mockUseQuery = jest.fn();
|
||||
jest.mock('react-query', () => {
|
||||
const actual = jest.requireActual('react-query');
|
||||
|
||||
@ -34,9 +34,6 @@ export const getDefaultMessage = (value) => {
|
||||
};
|
||||
|
||||
export const getActionMessage = (message, action) => {
|
||||
console.log('message', message);
|
||||
console.log('action', action);
|
||||
|
||||
if (message.includes('entry')) {
|
||||
return `${message} (${action.model})`;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user