2023-07-14 23:18:38 +01:00
|
|
|
import { initializeIcons } from "@fluentui/react";
|
2020-05-26 03:30:55 +01:00
|
|
|
import { configure } from "enzyme";
|
2021-03-29 19:31:52 +01:00
|
|
|
import Adapter from "enzyme-adapter-react-16";
|
2020-05-26 03:30:55 +01:00
|
|
|
import "jest-canvas-mock";
|
2023-07-14 23:18:38 +01:00
|
|
|
import enableHooks from "jest-react-hooks-shallow";
|
2021-03-29 19:31:52 +01:00
|
|
|
import { TextDecoder, TextEncoder } from "util";
|
2020-05-26 03:30:55 +01:00
|
|
|
configure({ adapter: new Adapter() });
|
2021-01-19 22:31:55 +00:00
|
|
|
initializeIcons();
|
2020-05-26 03:30:55 +01:00
|
|
|
|
|
|
|
if (typeof window.URL.createObjectURL === "undefined") {
|
|
|
|
Object.defineProperty(window.URL, "createObjectURL", { value: () => {} });
|
|
|
|
}
|
|
|
|
|
2023-07-14 23:18:38 +01:00
|
|
|
enableHooks(jest, { dontMockByDefault: true });
|
|
|
|
|
|
|
|
const localStorageMock = (function () {
|
|
|
|
let store: { [key: string]: string } = {};
|
|
|
|
return {
|
|
|
|
getItem: function (key: string) {
|
|
|
|
return store[key] || null;
|
|
|
|
},
|
|
|
|
setItem: function (key: string, value: string) {
|
|
|
|
store[key] = value.toString();
|
|
|
|
},
|
|
|
|
removeItem: function (key: string) {
|
|
|
|
delete store[key];
|
|
|
|
},
|
|
|
|
clear: function () {
|
|
|
|
store = {};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
|
|
|
Object.defineProperty(window, "localStorage", {
|
|
|
|
value: localStorageMock,
|
|
|
|
});
|
|
|
|
|
2020-05-26 03:30:55 +01:00
|
|
|
// TODO Remove when jquery and documentdbclient SDK are removed
|
|
|
|
(<any>window).$ = (<any>window).jQuery = require("jquery");
|
|
|
|
(<any>global).$ = (<any>global).$.jQuery = require("jquery");
|
|
|
|
require("jquery-ui-dist/jquery-ui");
|
2021-03-29 19:31:52 +01:00
|
|
|
(<any>global).TextEncoder = TextEncoder;
|
|
|
|
(<any>global).TextDecoder = TextDecoder;
|