0

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?

AlexProutorov
  • 677
  • 11
  • 22
  • 1
    See 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 Answers1

0

I came up with a simple replacement of $timeout:

const $timeout = (func) => {
    func();
};

which I pass to controller

AlexProutorov
  • 677
  • 11
  • 22