Can't bind since it's not a known property Angular Unit Tests
up vote
0
down vote
favorite
I'm writing a unit test for a component. It is supposed to be a pop-up component. My idea is to inject it with an element so it pops up.
Where am I doing it wrong ?
Can't bind to 'forEl' since it isn't a known property of 'ctr-info-popup'.
@Component({
template: `
<div #forEl class="bla" (click)="onMouseOver($event)"></div>
<ctr-info-popup [forEl]="context.forEl" [(show)]="context.show">
<div class="penalty-container">
<span class="penalty-title" [ngClass]="{'no-changes': !context.canChange}">{{context.title}}</span>
<span class="penalty" *ngFor="let penalty of context.penalties">{{penalty}}</span>
</div>
</ctr-info-popup>
`
})
class TestHostComponent{
context = null;
@ViewChild('forEl', {read: ElementRef}) forEl: ElementRef<HTMLDivElement>;
onMouseOver(event) {
this.context = {
forEl: this.forEl,
show: true,
canChange: false,
title: 'Test title',
penalties: ['p1', 'p2']
}
}
}
angular unit-testing jasmine karma-jasmine
New contributor
add a comment |
up vote
0
down vote
favorite
I'm writing a unit test for a component. It is supposed to be a pop-up component. My idea is to inject it with an element so it pops up.
Where am I doing it wrong ?
Can't bind to 'forEl' since it isn't a known property of 'ctr-info-popup'.
@Component({
template: `
<div #forEl class="bla" (click)="onMouseOver($event)"></div>
<ctr-info-popup [forEl]="context.forEl" [(show)]="context.show">
<div class="penalty-container">
<span class="penalty-title" [ngClass]="{'no-changes': !context.canChange}">{{context.title}}</span>
<span class="penalty" *ngFor="let penalty of context.penalties">{{penalty}}</span>
</div>
</ctr-info-popup>
`
})
class TestHostComponent{
context = null;
@ViewChild('forEl', {read: ElementRef}) forEl: ElementRef<HTMLDivElement>;
onMouseOver(event) {
this.context = {
forEl: this.forEl,
show: true,
canChange: false,
title: 'Test title',
penalties: ['p1', 'p2']
}
}
}
angular unit-testing jasmine karma-jasmine
New contributor
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm writing a unit test for a component. It is supposed to be a pop-up component. My idea is to inject it with an element so it pops up.
Where am I doing it wrong ?
Can't bind to 'forEl' since it isn't a known property of 'ctr-info-popup'.
@Component({
template: `
<div #forEl class="bla" (click)="onMouseOver($event)"></div>
<ctr-info-popup [forEl]="context.forEl" [(show)]="context.show">
<div class="penalty-container">
<span class="penalty-title" [ngClass]="{'no-changes': !context.canChange}">{{context.title}}</span>
<span class="penalty" *ngFor="let penalty of context.penalties">{{penalty}}</span>
</div>
</ctr-info-popup>
`
})
class TestHostComponent{
context = null;
@ViewChild('forEl', {read: ElementRef}) forEl: ElementRef<HTMLDivElement>;
onMouseOver(event) {
this.context = {
forEl: this.forEl,
show: true,
canChange: false,
title: 'Test title',
penalties: ['p1', 'p2']
}
}
}
angular unit-testing jasmine karma-jasmine
New contributor
I'm writing a unit test for a component. It is supposed to be a pop-up component. My idea is to inject it with an element so it pops up.
Where am I doing it wrong ?
Can't bind to 'forEl' since it isn't a known property of 'ctr-info-popup'.
@Component({
template: `
<div #forEl class="bla" (click)="onMouseOver($event)"></div>
<ctr-info-popup [forEl]="context.forEl" [(show)]="context.show">
<div class="penalty-container">
<span class="penalty-title" [ngClass]="{'no-changes': !context.canChange}">{{context.title}}</span>
<span class="penalty" *ngFor="let penalty of context.penalties">{{penalty}}</span>
</div>
</ctr-info-popup>
`
})
class TestHostComponent{
context = null;
@ViewChild('forEl', {read: ElementRef}) forEl: ElementRef<HTMLDivElement>;
onMouseOver(event) {
this.context = {
forEl: this.forEl,
show: true,
canChange: false,
title: 'Test title',
penalties: ['p1', 'p2']
}
}
}
angular unit-testing jasmine karma-jasmine
angular unit-testing jasmine karma-jasmine
New contributor
New contributor
New contributor
asked yesterday
Abdullah chishti
1
1
New contributor
New contributor
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Abdullah chishti is a new contributor. Be nice, and check out our Code of Conduct.
Abdullah chishti is a new contributor. Be nice, and check out our Code of Conduct.
Abdullah chishti is a new contributor. Be nice, and check out our Code of Conduct.
Abdullah chishti is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204335%2fcant-bind-since-its-not-a-known-property-angular-unit-tests%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password