|
|
@ -9,8 +9,7 @@ const { createServer } = require('http-server'); |
|
|
|
|
|
|
|
const components = uniq( |
|
|
|
glob |
|
|
|
.sync('components/*/*.md', { |
|
|
|
ignore: '**/{__tests__,_util,version,index.tsx}', |
|
|
|
.sync('components/!(overview)/*.md', { |
|
|
|
cwd: join(process.cwd()), |
|
|
|
dot: false, |
|
|
|
}) |
|
|
@ -35,13 +34,13 @@ describe('site test', () => { |
|
|
|
|
|
|
|
const handleComponentName = (name) => { |
|
|
|
const componentName = name.split('/')[1]; |
|
|
|
return componentName.toLowerCase().replace('-', ''); |
|
|
|
return componentName.toLowerCase().replace('-cn', '').replace('-', ''); |
|
|
|
}; |
|
|
|
|
|
|
|
const expectComponent = async (component) => { |
|
|
|
const { status, $ } = await render(`/${component}/`); |
|
|
|
expect(status).toBe(200); |
|
|
|
expect($('main h1').text().toLowerCase()).toMatch(handleComponentName(component)); |
|
|
|
expect($('h1').text().toLowerCase()).toMatch(handleComponentName(component)); |
|
|
|
}; |
|
|
|
|
|
|
|
beforeAll(() => { |
|
|
@ -73,10 +72,22 @@ describe('site test', () => { |
|
|
|
expect(status).toBe(200); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Overview en', async () => { |
|
|
|
const { status, $ } = await render('/components/overview'); |
|
|
|
expect(status).toBe(200); |
|
|
|
expect($('h1').text()).toMatch(`Overview`); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Overview zh', async () => { |
|
|
|
const { status, $ } = await render('/components/overview-cn'); |
|
|
|
expect(status).toBe(200); |
|
|
|
expect($('h1').text()).toMatch(`组件总览`); |
|
|
|
}); |
|
|
|
|
|
|
|
for (const component of components) { |
|
|
|
if (component.split('/').length < 3) { |
|
|
|
it(`Component ${component} zh Page`, async () => { |
|
|
|
await expectComponent(component); |
|
|
|
await expectComponent(`${component}-cn`); |
|
|
|
}); |
|
|
|
|
|
|
|
it(`Component ${component} en Page`, async () => { |
|
|
|