mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 18:30:29 +00:00
feat: make translation test fail if hardcoded strings are found
This commit is contained in:
parent
d27f92fb01
commit
e704abcb03
1 changed files with 14 additions and 16 deletions
|
|
@ -88,22 +88,20 @@ function walk(dir, report) {
|
|||
}
|
||||
});
|
||||
}
|
||||
const report = [];
|
||||
|
||||
describe('i18n hardcoded string scan', () => {
|
||||
it('should print hardcoded strings with suggested keys', () => {
|
||||
const report = [];
|
||||
walk(directoryToScan, report);
|
||||
walk(directoryToScan, report);
|
||||
|
||||
if (report.length === 0) {
|
||||
console.log('✅ No hardcoded strings found.');
|
||||
} else {
|
||||
console.log('🚨 Hardcoded strings found:');
|
||||
report.forEach((row) => {
|
||||
console.log(`File: ${row.file}, Line: ${row.line}, String: "${row.string}", Suggested Key: ${row.key}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Optional: expect no hardcoded strings if you want the test to fail in that case
|
||||
// expect(report.length).toBe(0);
|
||||
if (report.length !== 0) {
|
||||
describe.each(report)('Missing translation key', (entry) => {
|
||||
it(`should not have "${entry.string}" in ${entry.file} at line ${entry.line}`, () => {
|
||||
expect(entry.string).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
describe('Missing translation key', () => {
|
||||
it('No hardcoded strings found', () => {
|
||||
expect(true).toBe(true); // or just skip
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue