Frage

I am using jasmine to test my front end, and have a spy set up to watch for the edit function to be called within a controller. The callback takes a message and either brings up the edit view or throws an error.

spyOn(edit, "edit").andCallFake (callback) ->
    console.log(callback)
    callback()

I also have a spy setup to watch for a function in the model that fetches an updated version of the item within the edit controller.

spyOn(ag, "fetchLatestVersion").andCallFake (callback) ->
    console.log(callback)
    callback()

This function returns a message that gets sent to the edit callback and then displays the view or throws an error.

My edit function is running correctly until it gets to the fetchLatestVersion() function and then it doesn't seem to want to run the callback and doesn't even seem to output what the callback is. Any help with jasmine's .andCallFake() would be much appreciated.

Thanks in advance!

EDIT:

I just removed the edit spy (ended up being unnecessary) and my error has since changed. I am receiving the correct callback function from .fetchLatestVersion(), but I end up getting an error saying:

Error: Expected a spy, but got Function.

Let me know if you need more information. Thanks again!

War es hilfreich?

Lösung

This turned out to be an issue with Spine (the frontend framework) and how it finds objects. It makes a clone rather than returning the actual object. By changing the records to irecords I was able to get the test to pass correctly!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top