mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +08:00
5b23a6aac2
* chore(deps-dev): bump glob from 9.3.5 to 10.0.0 Bumps [glob](https://github.com/isaacs/node-glob) from 9.3.5 to 10.0.0. - [Release notes](https://github.com/isaacs/node-glob/releases) - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](https://github.com/isaacs/node-glob/compare/v9.3.5...v10.0.0) --- updated-dependencies: - dependency-name: glob dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore: upgrade glob usage --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { globSync } from 'glob';
|
|
import * as React from 'react';
|
|
import { renderToString } from 'react-dom/server';
|
|
import type { Options } from '../../tests/shared/demoTest';
|
|
|
|
(global as any).testConfig = {};
|
|
|
|
jest.mock('../../tests/shared/demoTest', () => {
|
|
function fakeDemoTest(name: string, option: Options = {}) {
|
|
(global as any).testConfig[name] = option;
|
|
}
|
|
|
|
fakeDemoTest.rootPropsTest = () => {};
|
|
|
|
return fakeDemoTest;
|
|
});
|
|
|
|
describe('node', () => {
|
|
beforeAll(() => {
|
|
jest.useFakeTimers().setSystemTime(new Date('2016-11-22'));
|
|
});
|
|
|
|
// Find the component exist demo test file
|
|
const files = globSync(`./components/*/__tests__/demo.test.@(j|t)s?(x)`);
|
|
|
|
files.forEach((componentTestFile) => {
|
|
const componentName = componentTestFile.match(/components\/([^/]*)\//)![1];
|
|
|
|
// Test for ssr
|
|
describe(componentName, () => {
|
|
const demoList = globSync(`./components/${componentName}/demo/*.tsx`);
|
|
|
|
// Use mock to get config
|
|
require(`../../${componentTestFile}`); // eslint-disable-line global-require, import/no-dynamic-require
|
|
const option = (global as any).testConfig?.[componentName];
|
|
|
|
demoList.forEach((demoFile) => {
|
|
const skip: string[] = option?.skip || [];
|
|
const test = skip.some((skipMarkdown) => demoFile.includes(skipMarkdown)) ? it.skip : it;
|
|
|
|
test(demoFile, () => {
|
|
const Demo = require(`../../${demoFile}`).default; // eslint-disable-line global-require, import/no-dynamic-require
|
|
expect(() => {
|
|
renderToString(<Demo />);
|
|
}).not.toThrow();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|