ant-design/tests/shared/demoTest.js

20 lines
652 B
JavaScript
Raw Normal View History

import glob from 'glob'
import { render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
2016-11-23 12:13:36 +08:00
import MockDate from 'mockdate';
export default function demoTest(component, options = {}) {
const testMethod = options.skip ? test.skip : test;
const files = glob.sync(`./components/${component}/demo/*.md`);
files.forEach(file => {
testMethod(`renders ${file} correctly`, () => {
2016-11-23 14:30:21 +08:00
MockDate.set(1479772800000, new Date().getTimezoneOffset()); // 2016-11-22
const demo = require('../.' + file);
const wrapper = render(demo);
expect(renderToJson(wrapper)).toMatchSnapshot();
2016-11-23 12:13:36 +08:00
MockDate.reset();
});
});
}