Home Test scope variables inside a non-scope method that is initiated inside if condition
Reply: 0

Test scope variables inside a non-scope method that is initiated inside if condition

user611
1#
user611 Published in April 26, 2018, 1:44 pm

Code:

if($scope.someValue){
init();
}

var init = function(){
$scope.anotherVal = true;
}

Test case:------------------------

describe('test 1', function(){
it('spec 1', function(){

 //I could'nt figure out how to initiate the init() method in my test case?

 $scope.someValue = true;
 expect($scope.anotherVal).toEqual(true);
});
});

//error: Expecting undefined to equal to true.

Can anyone help me figure out how to initiate the init() method. Moving the if condition into another method is not an option.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.37225 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO