mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 03:39:55 +00:00
webdriver ajax stub
This commit is contained in:
parent
baa3c1461c
commit
239d425940
4
.gitignore
vendored
4
.gitignore
vendored
@ -11,7 +11,7 @@ coverage
|
||||
.grunt
|
||||
.lock-wscript
|
||||
build/Release
|
||||
node_modules
|
||||
/node_modules/**/*
|
||||
jspm_modules
|
||||
.npm
|
||||
.node_repl_history
|
||||
@ -82,4 +82,4 @@ Temporary Items
|
||||
*.rej
|
||||
*.bak
|
||||
|
||||
!/tests/node_modules/webdriverajaxstub/index.js
|
||||
!/tests/node_modules/**/*
|
33
tests/node_modules/webdriverajaxstub/index.js
generated
vendored
Normal file
33
tests/node_modules/webdriverajaxstub/index.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
function plugin (wdInstance, requests) {
|
||||
if (typeof wdInstance.addCommand !== 'function') {
|
||||
throw new Error('You can\'t use WebdriverAjaxStub with this version of WebdriverIO');
|
||||
}
|
||||
|
||||
function stub(requests, done) {
|
||||
window.XMLHttpRequest = function () {
|
||||
this.open = function (method, url) {
|
||||
this.method = method;
|
||||
this.url = url;
|
||||
};
|
||||
|
||||
this.send = function () {
|
||||
this.status = 200;
|
||||
this.readyState = 4;
|
||||
const response = requests.shift() || [];
|
||||
this.response = response;
|
||||
this.responseText = response;
|
||||
this.onreadystatechange();
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
wdInstance.addCommand('setupStub', function() {
|
||||
return wdInstance.executeAsync(stub, requests);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.init = plugin;
|
Loading…
x
Reference in New Issue
Block a user