UNPKG

ngx-i18nsupport-lib

Version:

A Typescript library to work with Angular generated i18n files (xliff, xmb)

121 lines 6.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tag_mapping_1 = require("./tag-mapping"); /** * Created by roobm on 02.06.2017. * Testcases for Mapping from normalized tag names to placeholder names. */ describe('tag mapping spec', function () { it('should map START_EMPHASISED_TEXT to em', function () { var placeholderName = 'START_EMPHASISED_TEXT'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(tagname).toBe('em'); }); it('should map START_BOLD_TEXT to b', function () { var placeholderName = 'START_BOLD_TEXT'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(tagname).toBe('b'); }); it('should map TAG_IMG to img', function () { var placeholderName = 'TAG_IMG'; var starttagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(starttagname).toBe(null); expect(new tag_mapping_1.TagMapping().isEmptyTagPlaceholderName(placeholderName)).toBeTruthy(); var emptytagname = new tag_mapping_1.TagMapping().getTagnameFromEmptyTagPlaceholderName(placeholderName); expect(emptytagname).toBe('img'); }); it('should map LINE_BREAK to br', function () { var placeholderName = 'LINE_BREAK'; var starttagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(starttagname).toBe(null); expect(new tag_mapping_1.TagMapping().isEmptyTagPlaceholderName(placeholderName)).toBeTruthy(); var emptytagname = new tag_mapping_1.TagMapping().getTagnameFromEmptyTagPlaceholderName(placeholderName); expect(emptytagname).toBe('br'); }); it('should map START_LINK to a', function () { var placeholderName = 'START_LINK'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(tagname).toBe('a'); }); it('should map START_LINK_1 to a', function () { var placeholderName = 'START_LINK_1'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(tagname).toBe('a'); }); it('should map START_LINK_100 to a', function () { var placeholderName = 'START_LINK_100'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromStartTagPlaceholderName(placeholderName); expect(tagname).toBe('a'); }); it('should map CLOSE_TAG_IMG to img', function () { var placeholderName = 'CLOSE_TAG_IMG'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromCloseTagPlaceholderName(placeholderName); expect(tagname).toBe('img'); }); it('should map CLOSE_LINK to a', function () { var placeholderName = 'CLOSE_LINK'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromCloseTagPlaceholderName(placeholderName); expect(tagname).toBe('a'); }); it('should map CLOSE_LINK_1 to a', function () { var placeholderName = 'CLOSE_LINK_1'; var tagname = new tag_mapping_1.TagMapping().getTagnameFromCloseTagPlaceholderName(placeholderName); expect(tagname).toBe('a'); }); it('should map tag a to START_LINK', function () { var tagname = 'a'; var placeholderName = new tag_mapping_1.TagMapping().getStartTagPlaceholderName(tagname, 0); expect(placeholderName).toBe('START_LINK'); }); it('should map tag a to START_LINK with index', function () { var tagname = 'a'; var placeholderName = new tag_mapping_1.TagMapping().getStartTagPlaceholderName(tagname, 7); expect(placeholderName).toBe('START_LINK_7'); }); it('should map end tag img to CLOSE_TAG_IMG', function () { var tagname = 'img'; var placeholderName = new tag_mapping_1.TagMapping().getCloseTagPlaceholderName(tagname); expect(placeholderName).toBe('CLOSE_TAG_IMG'); }); it('should map end tag strange to CLOSE_TAG_STRANGE', function () { var tagname = 'strange'; var placeholderName = new tag_mapping_1.TagMapping().getCloseTagPlaceholderName(tagname); expect(placeholderName).toBe('CLOSE_TAG_STRANGE'); }); it('should map end tag b to CLOSE_BOLD_TEXT', function () { var tagname = 'b'; var placeholderName = new tag_mapping_1.TagMapping().getCloseTagPlaceholderName(tagname); expect(placeholderName).toBe('CLOSE_BOLD_TEXT'); }); it('should map tag br to LINE_BREAK', function () { var tagname = 'br'; var placeholderName = new tag_mapping_1.TagMapping().getEmptyTagPlaceholderName(tagname, 0); expect(placeholderName).toBe('LINE_BREAK'); }); it('should map tag img to TAG_IMG', function () { var tagname = 'img'; var placeholderName = new tag_mapping_1.TagMapping().getEmptyTagPlaceholderName(tagname, 0); expect(placeholderName).toBe('TAG_IMG'); }); it('should map tag img to TAG_IMG with index', function () { var tagname = 'img'; var placeholderName = new tag_mapping_1.TagMapping().getEmptyTagPlaceholderName(tagname, 1); expect(placeholderName).toBe('TAG_IMG_1'); }); it('should map special ctype for br', function () { var tagname = 'br'; var ctype = new tag_mapping_1.TagMapping().getCtypeForTag(tagname); expect(ctype).toBe('lb'); }); it('should map special ctype for img', function () { var tagname = 'IMG'; var ctype = new tag_mapping_1.TagMapping().getCtypeForTag(tagname); expect(ctype).toBe('image'); }); it('should map ctype for any tag', function () { var tagname = 'strangething'; var ctype = new tag_mapping_1.TagMapping().getCtypeForTag(tagname); expect(ctype).toBe('x-strangething'); }); }); //# sourceMappingURL=S:/experimente/ngx-i18nsupport-lib/src/impl/tag-mapping.spec.js.map