ant-design/tests/index.test.js

32 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-06-06 15:45:46 +08:00
// Test dist files
import fs from 'fs';
import path from 'path';
2016-12-08 11:08:13 +08:00
describe('antd dist files', () => {
const distFilesExisted = fs.existsSync(path.join(process.cwd(), 'dist', 'antd.js'));
2016-06-06 15:45:46 +08:00
if (!distFilesExisted) {
2016-07-09 18:10:11 +08:00
it('empty test case placeholder', () => {});
2016-06-06 15:45:46 +08:00
return;
}
2016-12-08 11:08:13 +08:00
const antd = require('../dist/antd'); // eslint-disable-line global-require
const antdInComponents = require('../components/'); // eslint-disable-line global-require
2016-06-06 15:45:46 +08:00
// https://github.com/ant-design/ant-design/issues/1638
// https://github.com/ant-design/ant-design/issues/1968
2016-12-20 23:59:29 +08:00
it('exports modules correctly', () => {
expect(Object.keys(antd)).toMatchSnapshot();
expect(Object.keys(antdInComponents)).toMatchSnapshot();
2016-06-06 15:45:46 +08:00
});
// https://github.com/ant-design/ant-design/issues/1970
// https://github.com/ant-design/ant-design/issues/1804
it('should be compatible in IE8', () => {
const antdJsContent = fs.readFileSync(path.join(process.cwd(), 'dist', 'antd.js'));
expect(
2016-06-06 15:45:46 +08:00
antdJsContent.toString()
.indexOf('function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }')
).toBe(-1);
2016-12-08 11:08:13 +08:00
});
});