mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: mise en place de la messagerie [#17]
This commit is contained in:
95
Front-End/jest.setup.js
Normal file
95
Front-End/jest.setup.js
Normal file
@ -0,0 +1,95 @@
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
// Supprimer les avertissements React act() en environnement de test
|
||||
global.IS_REACT_ACT_ENVIRONMENT = true;
|
||||
|
||||
// Mock window.matchMedia
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: jest.fn().mockImplementation((query) => ({
|
||||
matches: false,
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: jest.fn(), // deprecated
|
||||
removeListener: jest.fn(), // deprecated
|
||||
addEventListener: jest.fn(),
|
||||
removeEventListener: jest.fn(),
|
||||
dispatchEvent: jest.fn(),
|
||||
})),
|
||||
});
|
||||
|
||||
// Mock IntersectionObserver
|
||||
global.IntersectionObserver = class IntersectionObserver {
|
||||
constructor() {}
|
||||
observe() {
|
||||
return null;
|
||||
}
|
||||
disconnect() {
|
||||
return null;
|
||||
}
|
||||
unobserve() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// Mock WebSocket
|
||||
global.WebSocket = class WebSocket {
|
||||
constructor(url) {
|
||||
this.url = url;
|
||||
this.readyState = WebSocket.CONNECTING;
|
||||
setTimeout(() => {
|
||||
this.readyState = WebSocket.OPEN;
|
||||
if (this.onopen) this.onopen();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
send(data) {
|
||||
// Mock send
|
||||
}
|
||||
|
||||
close() {
|
||||
this.readyState = WebSocket.CLOSED;
|
||||
if (this.onclose) {
|
||||
this.onclose({
|
||||
code: 1000,
|
||||
reason: 'Normal closure',
|
||||
wasClean: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static get CONNECTING() {
|
||||
return 0;
|
||||
}
|
||||
static get OPEN() {
|
||||
return 1;
|
||||
}
|
||||
static get CLOSING() {
|
||||
return 2;
|
||||
}
|
||||
static get CLOSED() {
|
||||
return 3;
|
||||
}
|
||||
};
|
||||
|
||||
// Mock global pour fetch
|
||||
global.fetch = jest.fn(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
json: () => Promise.resolve([]),
|
||||
})
|
||||
);
|
||||
|
||||
// Mock ResizeObserver
|
||||
global.ResizeObserver = class ResizeObserver {
|
||||
constructor() {}
|
||||
observe() {
|
||||
return null;
|
||||
}
|
||||
disconnect() {
|
||||
return null;
|
||||
}
|
||||
unobserve() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user