diff --git a/packages/language-service/ivy/test/hybrid_visitor_spec.ts b/packages/language-service/ivy/test/hybrid_visitor_spec.ts index 556ac0a601..04d3578238 100644 --- a/packages/language-service/ivy/test/hybrid_visitor_spec.ts +++ b/packages/language-service/ivy/test/hybrid_visitor_spec.ts @@ -324,6 +324,45 @@ describe('findNodeAtPosition for template AST', () => { expect(node).toBeInstanceOf(e.PropertyRead); expect((node as e.PropertyRead).name).toBe('bar'); }); + + it('should locate switch value in ICUs', () => { + const {errors, nodes, position} = parse(`{sw¦itch, plural, other {text}}">`); + expect(errors).toBe(null); + const node = findNodeAtPosition(nodes, position); + expect(isExpressionNode(node!)).toBe(true); + expect(node).toBeInstanceOf(e.PropertyRead); + expect((node as e.PropertyRead).name).toBe('switch'); + }); + + it('should locate switch value in nested ICUs', () => { + const {errors, nodes, position} = parse( + `{expr, plural, other { {ne¦sted, plural, =1 { {{nestedInterpolation}} }} }}">`); + expect(errors).toBe(null); + const node = findNodeAtPosition(nodes, position); + expect(isExpressionNode(node!)).toBe(true); + expect(node).toBeInstanceOf(e.PropertyRead); + expect((node as e.PropertyRead).name).toBe('nested'); + }); + + it('should locate interpolation expressions in ICUs', () => { + const {errors, nodes, position} = + parse(`{expr, plural, other { {{ i¦nterpolation }} }}">`); + expect(errors).toBe(null); + const node = findNodeAtPosition(nodes, position); + expect(isExpressionNode(node!)).toBe(true); + expect(node).toBeInstanceOf(e.PropertyRead); + expect((node as e.PropertyRead).name).toBe('interpolation'); + }); + + it('should locate interpolation expressions in nested ICUs', () => { + const {errors, nodes, position} = parse( + `{expr, plural, other { {nested, plural, =1 { {{n¦estedInterpolation}} }} }}">`); + expect(errors).toBe(null); + const node = findNodeAtPosition(nodes, position); + expect(isExpressionNode(node!)).toBe(true); + expect(node).toBeInstanceOf(e.PropertyRead); + expect((node as e.PropertyRead).name).toBe('nestedInterpolation'); + }); }); describe('findNodeAtPosition for expression AST', () => {