Skip to content

Commit 9d73a89

Browse files
committed
test: add svg format validation test
1 parent 40084c8 commit 9d73a89

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
describe('piconss SVG format validation', () => {
5+
const themes = ['dark', 'light', 'default'];
6+
const iconDir = path.join(__dirname, '../icons');
7+
8+
const isSvgFormat = (fileContent) => {
9+
return fileContent.startsWith('<svg') && fileContent.endsWith('</svg>');
10+
};
11+
12+
themes.forEach((theme) => {
13+
const themeDir = path.join(iconDir, theme);
14+
test(`should validate all SVG icons in ${theme} theme`, () => {
15+
const icons = fs
16+
.readdirSync(themeDir)
17+
.filter((file) => file.endsWith('.svg'));
18+
icons.forEach((icon) => {
19+
console.log(`Checking icon: ${icon}`);
20+
const iconPath = path.join(themeDir, icon);
21+
const content = fs.readFileSync(iconPath, 'utf-8');
22+
expect(isSvgFormat(content)).toBe(true);
23+
});
24+
});
25+
});
26+
});

0 commit comments

Comments
 (0)