I have to test the Jasmine code specific / argument I'm writing for I want to test that my 'Foo' object has been triggered, so call foo.getList () method GET / foo Do and return results
I can check it in two ways: I could add foo.getList () to .spy Alternatively, I can use the $ HttpBackend.whenGET ("/ foo") and set my desired result there.
Is one supposed to be?
I think the HTTPBackend would be a better option, because it tests 'subsequent' in the logic flow. If I have used a detective , then I can not prove, for example, that I was not purely disturbed and was trying to solve a different URL.
However, I am looking at the inherited tests and they all use detective , and since I believe this code is better written by me (They can not be more novice then I bronze) I wonder if there is an advantage for using detective on $ httpBackend .
As you are testing foo.getList () , < Code> httpBackend . Once you test the function which only use foo.getList () , use a detective. This is the simplest solution to avoid duplication of exams.
Note that you are writing unit tests, each unit should be independent on other units.
No comments:
Post a Comment