From 8a6e54a06de5277da51425bb8918dfd563d2e938 Mon Sep 17 00:00:00 2001 From: cexbrayat Date: Wed, 4 Sep 2019 18:40:44 +0200 Subject: [PATCH] test(ivy): test case-insensitive selectors (#32548) Adds two acceptance tests to show a current difference in behavior between Ivy and VE. A directive with a selector `.Titledir` matches an element with `class="titleDir"` in VE but not in Ivy. Same thing for an attribute value. PR Close #32548 --- .../core/test/acceptance/directive_spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/packages/core/test/acceptance/directive_spec.ts b/packages/core/test/acceptance/directive_spec.ts index 31905992e8..d0fee53328 100644 --- a/packages/core/test/acceptance/directive_spec.ts +++ b/packages/core/test/acceptance/directive_spec.ts @@ -172,6 +172,23 @@ describe('directives', () => { expect(nodesWithDirective.length).toBe(1); }); + it('should match classes to directive selectors without case sensitivity', () => { + @Directive({selector: '.Titledir'}) + class TitleClassDirective { + } + + TestBed.configureTestingModule({declarations: [TestComponent, TitleClassDirective]}); + TestBed.overrideTemplate(TestComponent, ` +
+ `); + + const fixture = TestBed.createComponent(TestComponent); + const nodesWithDirective = + fixture.debugElement.queryAllNodes(By.directive(TitleClassDirective)); + + expect(nodesWithDirective.length).toBe(1); + }); + it('should NOT match classes to directive selectors', () => { TestBed.configureTestingModule({declarations: [TestComponent, TitleDirective]}); TestBed.overrideTemplate(TestComponent, ` @@ -184,6 +201,23 @@ describe('directives', () => { expect(nodesWithDirective.length).toBe(0); }); + it('should match attributes to directive selectors without case sensitivity', () => { + @Directive({selector: '[title=Titledir]'}) + class TitleAttributeDirective { + } + + TestBed.configureTestingModule({declarations: [TestComponent, TitleAttributeDirective]}); + TestBed.overrideTemplate(TestComponent, ` +
+ `); + + const fixture = TestBed.createComponent(TestComponent); + const nodesWithDirective = + fixture.debugElement.queryAllNodes(By.directive(TitleAttributeDirective)); + + expect(nodesWithDirective.length).toBe(1); + }); + it('should match directives with attribute selectors on outputs', () => { @Directive({selector: '[out]'}) class TestDir {