forked from wycats/merb-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mocks for XHR and confirm; Improved flow for the iframe; Fix even…
…ts and make fake submit events actually submit
- Loading branch information
Showing
3 changed files
with
56 additions
and
23 deletions.
There are no files selected for viewing
45 changes: 22 additions & 23 deletions
45
merb_screw_unit/app/views/layout/merb_screw_unit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Screw.Mock = { | ||
confirmWith: function(val) { | ||
Screw.Mock.confirmText = null; | ||
iframeWindow.confirm = function(str) { | ||
Screw.Mock.confirmText = str; | ||
return val; | ||
}; | ||
} | ||
}; | ||
Screw.XHR = function() {}; | ||
Screw.XHR.returns = function(str, type) { | ||
Screw.XHR.prototype.responseText = str; | ||
Screw.XHR.prototype.headers = {"content-type": "application/json"}; | ||
if(type == "xml") Screw.XHR.prototype.responseXML = $(str).get(); | ||
}; | ||
Screw.XHR.prototype = { | ||
abort: function() {}, | ||
getAllResponseHeaders: function() {}, | ||
getResponseHeader: function(header) { | ||
return this.headers[header.toLowerCase()]; | ||
}, | ||
open: function(method, url, async, user, pass) { | ||
Screw.XHR.url = url; | ||
}, | ||
send: function(content) { | ||
this.readyState = 4; | ||
this.status = 200; | ||
this.statusText = "OK"; | ||
}, | ||
setRequestHeader: function(label, value) {} | ||
}; |