-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cannot combine @input decorators with query decorators
closes #181 Signed-off-by: MG <m@sudo.eu>
- Loading branch information
Showing
4 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// tslint:disable: no-parameter-properties | ||
|
||
import { CommonModule } from '@angular/common'; | ||
import { ContentChild, Directive, NgModule } from '@angular/core'; | ||
import { MockBuilder, MockRender, ngMocks } from 'ng-mocks'; | ||
|
||
@Directive({ | ||
inputs: ['header'], | ||
selector: 'app-target', | ||
}) | ||
class TargetComponent { | ||
@ContentChild('header', { static: false } as any) | ||
public header: any; | ||
} | ||
|
||
@Directive({ | ||
inputs: ['header'], | ||
selector: '[appTarget]', | ||
}) | ||
class TargetDirective { | ||
@ContentChild('header', { static: false } as any) | ||
public header: any; | ||
} | ||
|
||
@NgModule({ | ||
declarations: [TargetComponent, TargetDirective], | ||
exports: [TargetComponent, TargetDirective], | ||
imports: [CommonModule], | ||
}) | ||
class TargetModule {} | ||
|
||
describe('issue-181:real', () => { | ||
beforeEach(() => MockBuilder().keep(TargetModule)); | ||
|
||
it('should create the component', () => { | ||
const fixture = MockRender(` | ||
<app-target appTarget> | ||
<ng-template #header> | ||
header | ||
</ng-template> | ||
</app-target> | ||
`); | ||
expect(ngMocks.findInstance(fixture.debugElement, TargetComponent).header).toBeTruthy(); | ||
expect(ngMocks.findInstance(fixture.debugElement, TargetDirective).header).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('issue-181:mock', () => { | ||
beforeEach(() => MockBuilder().mock(TargetModule)); | ||
|
||
// it fails in e2e with enabled ivy only. | ||
it('should create the component', () => { | ||
const fixture = MockRender(` | ||
<app-target appTarget> | ||
<ng-template #header> | ||
header | ||
</ng-template> | ||
</app-target> | ||
`); | ||
expect(ngMocks.findInstance(fixture.debugElement, TargetComponent).header).toBeTruthy(); | ||
expect(ngMocks.findInstance(fixture.debugElement, TargetDirective).header).toBeTruthy(); | ||
}); | ||
}); |