add MessageChannel mock

This commit is contained in:
Ashley Harrison
2025-01-22 10:49:55 +00:00
parent 79a434eb74
commit d6050a5675
+16
View File
@@ -42,6 +42,22 @@ window.matchMedia = (query) => ({
dispatchEvent: jest.fn(),
});
window.MessageChannel = jest.fn().mockImplementation(() => {
let onmessage: Function;
return {
port1: {
set onmessage(cb: Function) {
onmessage = cb;
},
},
port2: {
postMessage: (data: unknown) => {
onmessage?.({ data });
},
},
};
});
angular.module('grafana', ['ngRoute']);
angular.module('grafana.services', ['ngRoute', '$strap.directives']);
angular.module('grafana.panels', []);