fix(ivy): properly match directives on ng-template with * syntax (#29251)
PR Close #29251
This commit is contained in:

committed by
Kara Erickson

parent
3f32c0e674
commit
fa8669ac00
47
packages/core/test/acceptance/directive_spec.ts
Normal file
47
packages/core/test/acceptance/directive_spec.ts
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Component, Directive} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser';
|
||||
|
||||
describe('directives', () => {
|
||||
|
||||
describe('matching', () => {
|
||||
|
||||
@Directive({selector: 'ng-template[test]'})
|
||||
class TestDirective {
|
||||
}
|
||||
|
||||
@Component({selector: 'test-cmpt', template: ''})
|
||||
class TestComponent {
|
||||
}
|
||||
|
||||
it('should match directives on ng-template', () => {
|
||||
TestBed.configureTestingModule({declarations: [TestComponent, TestDirective]});
|
||||
TestBed.overrideTemplate(TestComponent, `<ng-template test></ng-template>`);
|
||||
|
||||
const fixture = TestBed.createComponent(TestComponent);
|
||||
const nodesWithDirective = fixture.debugElement.queryAllNodes(By.directive(TestDirective));
|
||||
|
||||
expect(nodesWithDirective.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should match directives on ng-template created by * syntax', () => {
|
||||
TestBed.configureTestingModule({declarations: [TestComponent, TestDirective]});
|
||||
TestBed.overrideTemplate(TestComponent, `<div *test></div>`);
|
||||
|
||||
const fixture = TestBed.createComponent(TestComponent);
|
||||
const nodesWithDirective = fixture.debugElement.queryAllNodes(By.directive(TestDirective));
|
||||
|
||||
expect(nodesWithDirective.length).toBe(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user