chore: update test

This commit is contained in:
MadCcc 2022-09-14 11:34:49 +08:00
parent d1be33f224
commit b7fe2078e8
3 changed files with 7 additions and 9 deletions

View File

@ -16,9 +16,6 @@ if (
} }
/* @remove-on-es-build-end */ /* @remove-on-es-build-end */
// Fix vite build error
export const theme = null;
export { default as Affix } from './affix'; export { default as Affix } from './affix';
export type { AffixProps } from './affix'; export type { AffixProps } from './affix';
export { default as Alert } from './alert'; export { default as Alert } from './alert';

View File

@ -71,7 +71,7 @@ function baseText(doInject: boolean, component: string, options: Options = {}) {
expect(errSpy).not.toHaveBeenCalledWith(expect.stringContaining('[Ant Design CSS-in-JS]')); expect(errSpy).not.toHaveBeenCalledWith(expect.stringContaining('[Ant Design CSS-in-JS]'));
errSpy(); errSpy.mockRestore();
}); });
} }
@ -96,6 +96,9 @@ function baseText(doInject: boolean, component: string, options: Options = {}) {
); );
} }
// Inject cssinjs cache to avoid create <style /> element
Demo = <StyleProvider cache={createCache()}>{Demo}</StyleProvider>;
if (typeof document === 'undefined') { if (typeof document === 'undefined') {
// Server // Server
expect(() => { expect(() => {
@ -112,7 +115,7 @@ function baseText(doInject: boolean, component: string, options: Options = {}) {
expect(child).toMatchSnapshot(); expect(child).toMatchSnapshot();
} }
errSpy(); errSpy.mockRestore();
}, },
); );
jest.useRealTimers(); jest.useRealTimers();

View File

@ -10,16 +10,14 @@ export function excludeWarning() {
originError(msg, ...rest); originError(msg, ...rest);
}); });
return () => { return errorSpy;
errorSpy.mockRestore();
};
} }
export default function excludeAllWarning() { export default function excludeAllWarning() {
let cleanUp: Function; let cleanUp: Function;
beforeAll(() => { beforeAll(() => {
cleanUp = excludeWarning(); cleanUp = excludeWarning().mockRestore;
}); });
afterAll(() => { afterAll(() => {