Skip to content

Commit c7e3c46

Browse files
authored
Merge pull request #3621 from iclanton/user/ianc/duplicate-resx-string-test
[localization utilities] Add a test for a RESX file with a duplicate entry.
2 parents e662910 + ee822c4 commit c7e3c46

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"comment": "",
5+
"type": "none",
6+
"packageName": "@rushstack/localization-utilities"
7+
}
8+
],
9+
"packageName": "@rushstack/localization-utilities",
10+
"email": "[email protected]"
11+
}

libraries/localization-utilities/src/parsers/test/__snapshots__/parseResx.test.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@ Array [
2424

2525
exports[`parseResx correctly ignores a string: terminal output 1`] = `Object {}`;
2626

27+
exports[`parseResx fails to parse a RESX file with a duplicate string: Loc file 1`] = `
28+
Object {
29+
"stringA": Object {
30+
"comment": undefined,
31+
"value": "Another string",
32+
},
33+
}
34+
`;
35+
36+
exports[`parseResx fails to parse a RESX file with a duplicate string: terminal output 1`] = `
37+
Object {
38+
"errorOutput": "test.resx(6,45): Duplicate string value \\"stringA\\"[n]",
39+
}
40+
`;
41+
2742
exports[`parseResx ignoreMissingResxComments when set to false, warns on a missing comment: Loc file 1`] = `
2843
Object {
2944
"stringWithoutAComment": Object {

libraries/localization-utilities/src/parsers/test/parseResx.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ describe(parseResx.name, () => {
5656
| 'resxWithSchema'
5757
| 'stringWithoutComment'
5858
| 'stringWithQuotemarks'
59-
| 'withNewlines',
59+
| 'withNewlines'
60+
| 'resxWithDuplicateEntry',
6061
optionsOverride: Partial<IParseResxOptions> = {}
6162
): Promise<void> {
6263
const content: string = await FileSystem.readFileAsync(`${__dirname}/testResxFiles/${filename}.resx`);
@@ -134,4 +135,8 @@ describe(parseResx.name, () => {
134135
});
135136
});
136137
});
138+
139+
it('fails to parse a RESX file with a duplicate string', async () => {
140+
await testResxAsync('resxWithDuplicateEntry');
141+
});
137142
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<root>
3+
<data name="stringA" xml:space="preserve">
4+
<value>A string</value>
5+
</data>
6+
<data name="stringA" xml:space="preserve">
7+
<value>Another string</value>
8+
</data>
9+
</root>

0 commit comments

Comments
 (0)