From e48e36bde3121a8631e86eef0d7b40453d37413f Mon Sep 17 00:00:00 2001 From: crisbeto Date: Thu, 9 Jan 2020 20:12:44 +0100 Subject: [PATCH] test(ivy): add test for class setters being invoked when not used (#34706) Adds a test that we should make pass once the latest styling refactor has landed. PR Close #34706 --- packages/core/test/acceptance/styling_spec.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/core/test/acceptance/styling_spec.ts b/packages/core/test/acceptance/styling_spec.ts index 4addfa16e2..9a74b70d63 100644 --- a/packages/core/test/acceptance/styling_spec.ts +++ b/packages/core/test/acceptance/styling_spec.ts @@ -2507,6 +2507,30 @@ describe('styling', () => { expect(trailing.className).toBe('foo', 'Expected class to be applied despite trailing space.'); }); + // TODO(FW-1360): re-enable this test once the new styling changes are in place. + xit('should not set inputs called class if they are not being used in the template', () => { + const logs: string[] = []; + + @Directive({selector: '[test]'}) + class MyDir { + @Input('class') + set className(value: string) { logs.push(value); } + } + + @Component({ + // Note that we shouldn't have a `class` attribute here. + template: `
` + }) + class MyComp { + } + + TestBed.configureTestingModule({declarations: [MyComp, MyDir]}); + const fixture = TestBed.createComponent(MyComp); + fixture.detectChanges(); + + expect(logs).toEqual([]); + }); + }); function assertStyleCounters(countForSet: number, countForRemove: number) {