Browse Source

Test case for warning message of importing all components (#9814)

* Add test case

* fix test case
pull/9832/head
偏右 7 years ago
committed by GitHub
parent
commit
f6f5fb3672
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      components/__tests__/index.test.js
  2. 1
      components/index.tsx

10
components/__tests__/index.test.js

@ -1,7 +1,15 @@
import * as antd from '..';
const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
const antd = require('..');
describe('antd', () => {
it('exports modules correctly', () => {
expect(Object.keys(antd)).toMatchSnapshot();
});
it('should hint when import all components', () => {
expect(warnSpy).toBeCalledWith(
'You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.'
);
warnSpy.mockRestore();
});
});

1
components/index.tsx

@ -2,7 +2,6 @@
// this file is not used if use https://github.com/ant-design/babel-plugin-import
const ENV = process.env.NODE_ENV;
if (ENV !== 'production' &&
ENV !== 'test' &&
typeof console !== 'undefined' &&
console.warn &&
typeof window !== 'undefined') {

Loading…
Cancel
Save