').nodes)).toContain([
'prop', new AbsoluteSourceSpan(7, 11)
]);
});
});
it('should provide absolute offsets of a quote', () => {
expect(humanizeExpressionSource(parse('
').nodes)).toContain([
'a:b', new AbsoluteSourceSpan(13, 16)
]);
});
describe('absolute offsets for template expressions', () => {
it('should work for simple cases', () => {
expect(
humanizeExpressionSource(parse('
{{item}}
').nodes))
.toContain(['items', new AbsoluteSourceSpan(25, 30)]);
});
it('should work with multiple bindings', () => {
expect(humanizeExpressionSource(parse('
').nodes))
.toEqual(jasmine.arrayContaining(
[['As', new AbsoluteSourceSpan(22, 24)], ['Bs', new AbsoluteSourceSpan(35, 37)]]));
});
});
describe('ICU expressions', () => {
it('is correct for variables and placeholders', () => {
const spans = humanizeExpressionSource(
parse('
{item.var, plural, other { {{item.placeholder}} items } }')
.nodes);
expect(spans).toContain(['item.var', new AbsoluteSourceSpan(12, 20)]);
expect(spans).toContain(['item.placeholder', new AbsoluteSourceSpan(40, 56)]);
});
it('is correct for variables and placeholders', () => {
const spans = humanizeExpressionSource(
parse(
'
{item.var, plural, other { {{item.placeholder}} {nestedVar, plural, other { {{nestedPlaceholder}} }}} }')
.nodes);
expect(spans).toContain(['item.var', new AbsoluteSourceSpan(12, 20)]);
expect(spans).toContain(['item.placeholder', new AbsoluteSourceSpan(40, 56)]);
expect(spans).toContain(['nestedVar', new AbsoluteSourceSpan(60, 69)]);
expect(spans).toContain(['nestedPlaceholder', new AbsoluteSourceSpan(89, 106)]);
});
});
});