From 9ed9ff40b3f21238ea0bc4fbb88985c142fd76c7 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Mon, 14 Nov 2016 10:41:46 -0800 Subject: [PATCH] test(compiler): improve xliff tests --- .../test/i18n/serializers/xliff_spec.ts | 63 ++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) diff --git a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts index 2dcadf090d..1db9851132 100644 --- a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts +++ b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts @@ -112,8 +112,8 @@ export function main(): void { }); }); - describe('errors', () => { - it('should throw when a placeholder has no id attribute', () => { + describe('structure errors', () => { + it('should throw when a trans-unit has no id attribute', () => { const XLIFF = ` @@ -131,25 +131,7 @@ export function main(): void { }).toThrowError(/ misses the "id" attribute/); }); - it('should throw on unknown message tags', () => { - const XLIFF = ` - - - - - - msg should contain only ph tags - - - -`; - - expect(() => { loadAsMap(XLIFF); }) - .toThrowError( - new RegExp(escapeRegExp(`[ERROR ->]msg should contain only ph tags`))); - }); - - it('should throw when a placeholder has no name attribute', () => { + it('should throw on duplicate trans-unit id', () => { const XLIFF = ` @@ -171,6 +153,45 @@ export function main(): void { }).toThrowError(/Duplicated translations for msg deadbeef/); }); }); + + describe('message errors', () => { + it('should throw on unknown message tags', () => { + const XLIFF = ` + + + + + + msg should contain only ph tags + + + +`; + + expect(() => { loadAsMap(XLIFF); }) + .toThrowError( + new RegExp(escapeRegExp(`[ERROR ->]msg should contain only ph tags`))); + }); + + it('should throw when a placeholder misses an id attribute', () => { + const XLIFF = ` + + + + + + + + + +`; + + expect(() => { + loadAsMap(XLIFF); + }).toThrowError(new RegExp(escapeRegExp(` misses the "id" attribute`))); + }); + + }); }); }); } \ No newline at end of file