You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import glob from 'glob'
|
|
|
|
import { render } from 'enzyme';
|
|
|
|
import { renderToJson } from 'enzyme-to-json';
|
|
|
|
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`, () => {
|
|
|
|
MockDate.set(1479772800000, new Date().getTimezoneOffset()); // 2016-11-22
|
|
|
|
const demo = require('../.' + file);
|
|
|
|
const wrapper = render(demo);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
MockDate.reset();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|