From eec9f4a84e9fbea6be309dde80d20c6b787a0aa4 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Wed, 30 Sep 2020 08:59:47 -0700 Subject: [PATCH] test(language-service): add test for multiple bound attributes in microsyntax (#39062) It used to be the case that all microsyntax bindings share the same source span, so the second bound attribute would overwrite the first. This has been fixed in #39036, this case is added to prevent regression. PR Close #39062 --- .../ivy/test/hybrid_visitor_spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/language-service/ivy/test/hybrid_visitor_spec.ts b/packages/language-service/ivy/test/hybrid_visitor_spec.ts index 36504d389b..ec452c9696 100644 --- a/packages/language-service/ivy/test/hybrid_visitor_spec.ts +++ b/packages/language-service/ivy/test/hybrid_visitor_spec.ts @@ -535,6 +535,19 @@ describe('findNodeAtPosition for microsyntax expression', () => { expect((node as t.BoundAttribute).name).toBe('ngForTrackBy'); }); + it('should locate first bound attribute when there are two', () => { + // It used to be the case that all microsyntax bindings share the same + // source span, so the second bound attribute would overwrite the first. + // This has been fixed in pr/39036, this case is added to prevent regression. + const {errors, nodes, position} = + parse(`
`); + expect(errors).toBe(null); + const node = findNodeAtPosition(nodes, position); + expect(isTemplateNode(node!)).toBe(true); + expect(node).toBeInstanceOf(t.BoundAttribute); + expect((node as t.BoundAttribute).name).toBe('ngForOf'); + }); + it('should locate bound attribute value', () => { const {errors, nodes, position} = parse(`
`); expect(errors).toBe(null);