Ant_Design_Pro ,React+Ts模板 ,修改了跳转其鉴权逻辑,添加接口请求加解密功能,修改了基本的登录/出 功能
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
const localStorageMock = {
|
|
|
|
|
getItem: jest.fn(),
|
|
|
|
|
setItem: jest.fn(),
|
|
|
|
|
removeItem: jest.fn(),
|
|
|
|
|
clear: jest.fn(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
global.localStorage = localStorageMock;
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(URL, 'createObjectURL', {
|
|
|
|
|
writable: true,
|
|
|
|
|
value: jest.fn(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
class Worker {
|
|
|
|
|
constructor(stringUrl) {
|
|
|
|
|
this.url = stringUrl;
|
|
|
|
|
this.onmessage = () => {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
postMessage(msg) {
|
|
|
|
|
this.onmessage(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
window.Worker = Worker;
|
|
|
|
|
|
|
|
|
|
/* eslint-disable global-require */
|
|
|
|
|
if (typeof window !== 'undefined') {
|
|
|
|
|
// ref: https://github.com/ant-design/ant-design/issues/18774
|
|
|
|
|
if (!window.matchMedia) {
|
|
|
|
|
Object.defineProperty(global.window, 'matchMedia', {
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
value: jest.fn(() => ({
|
|
|
|
|
matches: false,
|
|
|
|
|
addListener: jest.fn(),
|
|
|
|
|
removeListener: jest.fn(),
|
|
|
|
|
})),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (!window.matchMedia) {
|
|
|
|
|
Object.defineProperty(global.window, 'matchMedia', {
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
value: jest.fn((query) => ({
|
|
|
|
|
matches: query.includes('max-width'),
|
|
|
|
|
addListener: jest.fn(),
|
|
|
|
|
removeListener: jest.fn(),
|
|
|
|
|
})),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const errorLog = console.error;
|
|
|
|
|
Object.defineProperty(global.window.console, 'error', {
|
|
|
|
|
writable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
value: (...rest) => {
|
|
|
|
|
const logStr = rest.join('');
|
|
|
|
|
if (logStr.includes('Warning: An update to %s inside a test was not wrapped in act(...)')) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
errorLog(...rest);
|
|
|
|
|
},
|
|
|
|
|
});
|