Currently, I am attempting to implement a timeout function test within my application.
Within the controller:
$scope.$watch('toy',function(toyVar){
if(toyVar == 1) {
//perform actions
} else {
$timeout(function() {
$window.alert('toy is old');
}, 3000);
}
});
Test file:
describe('test', function () {
var ctrl, scope;
beforeEach(module('testApp'));
beforeEach(inject(function (_$controller_, _$rootScope_) {
scope = _$rootScope_.$new();
ctrl = _$controller_('toyCtrl', {
$scope: scope
});
}));
describe('testing section', function() {
it('should validate the functionality of the timeout function', function() {
//uncertain about how to create the test here
})
})
});
I'm unsure on how to compose a test for the $timeout
segment of the code. Any assistance would be greatly appreciated! Thank you!