Reputation: 1
I am new in programming and this is the first time im asked to do unit testing in Angular and im a lil bit confused... I want to test this method in my component.ts:
isInputHidden = true;
showInput(){this.isInputHidden = false;}
spec.ts :
it('should show the input', () => {
component.isInputHidden == false;
let showInput = component.showInput();
expect(showInput).toBe(true);
})
When i run this test i get these errors : In jasmine ==> Expect undefined to equal true. In Terminal ==> Argument of type 'true' is not assignable to parameter of type 'Expected'. Someone can help me to figure out what should i change?
Upvotes: 0
Views: 3345
Reputation: 4238
Here is how to fix your test :
=
and not ==
showInput()
functionit('should show the input', () => {
component.isInputHidden = false; // removed a "="
component.showInput(); // your function will change isInputHidden directly
expect(component.isInputHidden).toBe(true); // test isInputHidden
Upvotes: 2