Here is my code:
var getCode = function(code) {
if (code = (new RegExp('[?&]' + encodeURIComponent(code) + '=([^&]*)'))
.exec(location.search))
return decodeURIComponent(code[1]);
};
$(document).ready(function() {
var code = getCode("code");
//some other function
and here is my test code:
it("check the code value of url", function() {
window.location.search = "http://ift.tt/20aW4KF";
var code = getCode("code");
expect(code).toEqual("testParam");
});
Whenever I try to run this as jasmine test it shows runtimeexception. Is there anyway I can set the location url and check it?
Thank you very much for your help
Aucun commentaire:
Enregistrer un commentaire