mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-12 15:19:58 +08:00
edbbaac5f9
new Date returns a UTC time in node Close #9743
23 lines
785 B
JavaScript
23 lines
785 B
JavaScript
import glob from 'glob';
|
|
import { render } from 'enzyme';
|
|
import MockDate from 'mockdate';
|
|
import moment from 'moment';
|
|
|
|
export default function demoTest(component, options = {}) {
|
|
const files = glob.sync(`./components/${component}/demo/*.md`);
|
|
|
|
files.forEach((file) => {
|
|
let testMethod = options.skip === true ? test.skip : test;
|
|
if (Array.isArray(options.skip) && options.skip.some(c => file.includes(c))) {
|
|
testMethod = test.skip;
|
|
}
|
|
testMethod(`renders ${file} correctly`, () => {
|
|
MockDate.set(moment('2016-11-22'));
|
|
const demo = require(`../.${file}`).default; // eslint-disable-line global-require, import/no-dynamic-require
|
|
const wrapper = render(demo);
|
|
expect(wrapper).toMatchSnapshot();
|
|
MockDate.reset();
|
|
});
|
|
});
|
|
}
|