mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +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', () => {
|
walk(directoryToScan, report);
|
||||||
it('should print hardcoded strings with suggested keys', () => {
|
|
||||||
const report = [];
|
|
||||||
walk(directoryToScan, report);
|
|
||||||
|
|
||||||
if (report.length === 0) {
|
if (report.length !== 0) {
|
||||||
console.log('✅ No hardcoded strings found.');
|
describe.each(report)('Missing translation key', (entry) => {
|
||||||
} else {
|
it(`should not have "${entry.string}" in ${entry.file} at line ${entry.line}`, () => {
|
||||||
console.log('🚨 Hardcoded strings found:');
|
expect(entry.string).toBeFalsy();
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
});
|
} else {
|
||||||
|
describe('Missing translation key', () => {
|
||||||
|
it('No hardcoded strings found', () => {
|
||||||
|
expect(true).toBe(true); // or just skip
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue