I need to create unit test for a method in Angular controller that utilizes $timeout service. The problem is that I was told not to use inject. So I have to mock $timeout myself. How can I do it using sinon?
Asked
Active
Viewed 160 times
0
-
1See http://stackoverflow.com/questions/37525588/unit-test-angularjs-directive-which-contains-private-timeout-with-jasmine . The same applies to Mocha/Sinon. It is not clear what *not to use inject* should mean. – Estus Flask Sep 12 '16 at 14:48
1 Answers
0
I came up with a simple replacement of $timeout:
const $timeout = (func) => {
func();
};
which I pass to controller

AlexProutorov
- 677
- 11
- 22