@ -15,7 +15,9 @@ import {getNativeByIndex} from '../../src/render3/util/view_utils';
|
||||
import {TemplateFixture} from './render_util';
|
||||
|
||||
describe('Runtime i18n', () => {
|
||||
afterEach(() => { setDelayProjection(false); });
|
||||
afterEach(() => {
|
||||
setDelayProjection(false);
|
||||
});
|
||||
describe('getTranslationForTemplate', () => {
|
||||
it('should crop messages for the selected template', () => {
|
||||
let message = `simple text`;
|
||||
@ -69,10 +71,12 @@ describe('Runtime i18n', () => {
|
||||
const MSG_DIV = `simple text`;
|
||||
const nbConsts = 1;
|
||||
const index = 0;
|
||||
const opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
// Check debug
|
||||
const debugOps = (opCodes as any).create.debug !.operations;
|
||||
const debugOps = (opCodes as any).create.debug!.operations;
|
||||
expect(debugOps[0].__raw_opCode).toBe('simple text');
|
||||
expect(debugOps[0].type).toBe('Create Text Node');
|
||||
expect(debugOps[0].nodeIndex).toBe(1);
|
||||
@ -100,7 +104,9 @@ describe('Runtime i18n', () => {
|
||||
const index = 1;
|
||||
const elementIndex = 2;
|
||||
const elementIndex2 = 3;
|
||||
const opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual({
|
||||
vars: 5,
|
||||
@ -136,7 +142,9 @@ describe('Runtime i18n', () => {
|
||||
const MSG_DIV = `Hello <20>0<EFBFBD>!`;
|
||||
const nbConsts = 2;
|
||||
const index = 1;
|
||||
const opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect((opCodes as any).update.debug.operations).toEqual([
|
||||
{__raw_opCode: 8, checkBit: 1, type: 'Text', nodeIndex: 2, text: 'Hello <20>0<EFBFBD>!'}
|
||||
@ -161,7 +169,9 @@ describe('Runtime i18n', () => {
|
||||
const MSG_DIV = `Hello <20>0<EFBFBD> and <20>1<EFBFBD>, again <20>0<EFBFBD>!`;
|
||||
const nbConsts = 2;
|
||||
const index = 1;
|
||||
const opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual({
|
||||
vars: 1,
|
||||
@ -195,7 +205,9 @@ describe('Runtime i18n', () => {
|
||||
let index = 1;
|
||||
const firstTextNode = 3;
|
||||
const rootTemplate = 2;
|
||||
let opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
let opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual({
|
||||
vars: 2,
|
||||
@ -225,7 +237,9 @@ describe('Runtime i18n', () => {
|
||||
index = 0;
|
||||
const spanElement = 1;
|
||||
const bElementSubTemplate = 2;
|
||||
opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV, 1); }, null, nbConsts, index);
|
||||
opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV, 1);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual({
|
||||
vars: 2,
|
||||
@ -252,7 +266,9 @@ describe('Runtime i18n', () => {
|
||||
nbConsts = 2;
|
||||
index = 0;
|
||||
const bElement = 1;
|
||||
opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV, 2); }, null, nbConsts, index);
|
||||
opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV, 2);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual({
|
||||
vars: 1,
|
||||
@ -277,7 +293,9 @@ describe('Runtime i18n', () => {
|
||||
}`;
|
||||
const nbConsts = 1;
|
||||
const index = 0;
|
||||
const opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
const tIcuIndex = 0;
|
||||
const icuCommentNodeIndex = index + 1;
|
||||
const firstTextNodeIndex = index + 2;
|
||||
@ -465,7 +483,9 @@ describe('Runtime i18n', () => {
|
||||
}`;
|
||||
const nbConsts = 1;
|
||||
const index = 0;
|
||||
const opCodes = getOpCodes(() => { ɵɵi18nStart(index, MSG_DIV); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nStart(index, MSG_DIV);
|
||||
}, null, nbConsts, index);
|
||||
const icuCommentNodeIndex = index + 1;
|
||||
const firstTextNodeIndex = index + 2;
|
||||
const nestedIcuCommentNodeIndex = index + 3;
|
||||
@ -497,18 +517,18 @@ describe('Runtime i18n', () => {
|
||||
cases: ['cat', 'dog', 'other'],
|
||||
create: [
|
||||
[
|
||||
'cats', nestedTextNodeIndex, nestedIcuCommentNodeIndex
|
||||
<< I18nMutateOpCode.SHIFT_PARENT |
|
||||
'cats', nestedTextNodeIndex,
|
||||
nestedIcuCommentNodeIndex << I18nMutateOpCode.SHIFT_PARENT |
|
||||
I18nMutateOpCode.AppendChild
|
||||
],
|
||||
[
|
||||
'dogs', nestedTextNodeIndex, nestedIcuCommentNodeIndex
|
||||
<< I18nMutateOpCode.SHIFT_PARENT |
|
||||
'dogs', nestedTextNodeIndex,
|
||||
nestedIcuCommentNodeIndex << I18nMutateOpCode.SHIFT_PARENT |
|
||||
I18nMutateOpCode.AppendChild
|
||||
],
|
||||
[
|
||||
'animals', nestedTextNodeIndex, nestedIcuCommentNodeIndex
|
||||
<< I18nMutateOpCode.SHIFT_PARENT |
|
||||
'animals', nestedTextNodeIndex,
|
||||
nestedIcuCommentNodeIndex << I18nMutateOpCode.SHIFT_PARENT |
|
||||
I18nMutateOpCode.AppendChild
|
||||
]
|
||||
],
|
||||
@ -599,8 +619,9 @@ describe('Runtime i18n', () => {
|
||||
const MSG_div_attr = ['title', MSG_title];
|
||||
const nbConsts = 2;
|
||||
const index = 1;
|
||||
const opCodes =
|
||||
getOpCodes(() => { ɵɵi18nAttributes(index, MSG_div_attr); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nAttributes(index, MSG_div_attr);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual([
|
||||
0b1, // bindings mask
|
||||
@ -616,8 +637,9 @@ describe('Runtime i18n', () => {
|
||||
const MSG_div_attr = ['title', MSG_title];
|
||||
const nbConsts = 2;
|
||||
const index = 1;
|
||||
const opCodes =
|
||||
getOpCodes(() => { ɵɵi18nAttributes(index, MSG_div_attr); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nAttributes(index, MSG_div_attr);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual([
|
||||
0b11, // bindings mask
|
||||
@ -632,8 +654,9 @@ describe('Runtime i18n', () => {
|
||||
const MSG_div_attr = ['title', MSG_title, 'aria-label', MSG_title];
|
||||
const nbConsts = 2;
|
||||
const index = 1;
|
||||
const opCodes =
|
||||
getOpCodes(() => { ɵɵi18nAttributes(index, MSG_div_attr); }, null, nbConsts, index);
|
||||
const opCodes = getOpCodes(() => {
|
||||
ɵɵi18nAttributes(index, MSG_div_attr);
|
||||
}, null, nbConsts, index);
|
||||
|
||||
expect(opCodes).toEqual([
|
||||
0b1, // bindings mask
|
||||
|
Reference in New Issue
Block a user