Skip to content

Commit

Permalink
add test for overweite mode with non existing target node
Browse files Browse the repository at this point in the history
  • Loading branch information
lotterfriends committed Dec 14, 2023
1 parent f335409 commit 8a25a84
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions __tests__/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2089,6 +2089,35 @@ describe('merge', () => {

expect(norm(result)).toEqual(norm(sourceFileContent));
});

it('should update translation without target', () => {
const sourceFileContent = `
<?xml version="1.0"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="de" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="appNotificationListSeeMore" datatype="html">
<source>see more...</source>
<target state="translated">mehr anzeigen...</target>
</trans-unit>
</body>
</file>
</xliff>`;

const destFileContent = `
<?xml version="1.0"?><xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="de" datatype="plaintext" original="ng2.template">
<body>
<trans-unit id="appNotificationListSeeMore" datatype="html">
<source>see more...</source>
</trans-unit>
</body>
</file>
</xliff>`;

const result = merge(sourceFileContent, destFileContent, {overwriteTargetWithTranslated: true});

expect(norm(result)).toEqual(norm(sourceFileContent));
});
});

function norm(xml: string): string {
Expand Down

0 comments on commit 8a25a84

Please sign in to comment.