I'm testing some JavaScript with the unit Jasmine and IOM (fake) wants to spy on an element of DOM I'm a JQuery selector
I have my imagination:
it ("must be able to dock dome calls", function () {spyOn ($ ("#se"), 'val ') And return ("bar"); result = $ ("#some"). Val (); Hope (results) .toqual ("bar");}); I have in my specrunner.html:
& lt; Input type = "hidden" id = "something" value = "foo" /> Unfortunately, fails with this type of: DOM calls should be able to duplicate 'bar' equals 'foo'.
This row is incorrect:
spyOn ( $ ("#th"), 'wall') and return ("bar"); Jasmin's SpyOn Function is expected to have two parameters. First is an existing object, the function name is the second string. You are passing the function name in the form of string ("well"), but you are not going to be in the first parameter as an existing object.
$ ("#some") ... is not an existing object. This is the result of a jQuery selector (return value). From, it will represent the mailed nodes to a jQuery object - like the type of array.
$ ... is an existing object.
$ .fn ... is an existing object.
$ ("#some") ... no - it's a jquery The result of the selector is . This will work:
this ("must be able to duplicate DOM calls", function () {//spyOn($.fn, "val") And return ("bar"); // pre-jasmine 2.0 syntax on Detective ($ .fn, "val") and. Return value ("bar"); // Jasmine 2.0 Syntax Vars result = $ ("# "). Val (); Hope (results). Tuquel (" bar ");});
Comments
Post a Comment