Skip to content

Commit 37f1bf9

Browse files
authored
test: update Chinese detected test case (ant-design#56908)
* test: update * test: update Chinese detected test case * update
1 parent 67c918f commit 37f1bf9

1 file changed

Lines changed: 18 additions & 29 deletions

File tree

components/__tests__/blog.test.ts

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
1-
const fs = require('fs');
1+
import fs from 'node:fs';
2+
import path from 'node:path';
23

3-
const path = require('path');
4+
const blogDir = path.join(__dirname, '../../docs/blog');
45

5-
const blogList = [
6-
'check-conduct',
7-
'contributor-development-maintenance-guide',
8-
'css-in-js',
9-
'extract-ssr',
10-
'getContainer',
11-
'github-actions-workflow',
12-
'issue-helper',
13-
'mock-project-build',
14-
'modal-hook-order',
15-
'testing-migrate',
16-
'render-times',
17-
'to-be-collaborator',
18-
'tooltip-align',
19-
'tree-shaking',
20-
'why-not-static',
21-
].map((blogName) => path.join(__dirname, `../../docs/blog/${blogName}.en-US.md`));
6+
const blogList = fs
7+
.readdirSync(blogDir, { withFileTypes: true })
8+
.filter((entry) => entry.isFile())
9+
.map((entry) => entry.name)
10+
.filter((file) => file.endsWith('.en-US.md'))
11+
.map((file) => path.join(blogDir, file));
2212

23-
describe('blog', () => {
13+
describe('Chinese detected in en-US blog', () => {
2414
it('should not include Chinese in en-US blog', () => {
25-
blogList.forEach((blog) => {
26-
fs.readFile(blog, (err: NodeJS.ErrnoException | null, data: Buffer) => {
27-
if (err) {
28-
return;
29-
}
30-
const includeChinese = /[\u4E00-\u9FA5]/.test(data.toString());
31-
expect(includeChinese).toBe(false);
32-
});
33-
});
15+
for (const blog of blogList) {
16+
const data = fs.readFileSync(blog, 'utf-8');
17+
const includeChinese = /[\u4E00-\u9FA5]/.test(data);
18+
if (includeChinese) {
19+
console.error('❌ 检测到中文:', blog);
20+
}
21+
expect(includeChinese).toBe(false);
22+
}
3423
});
3524
});

0 commit comments

Comments
 (0)