angular-mock-record
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -40,4 +40,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
}; | ||
MockUtilities.prototype.setClient = function (domain) { | ||
browser.executeScript(this.setClientRequest(domain)); | ||
}; | ||
MockUtilities.prototype.setClientRequest = function (domain) { | ||
var url = this.api_host + '/domain/' + domain; | ||
var xmlHttp = new XMLHttpRequest(); | ||
xmlHttp.open('GET', url, false); | ||
xmlHttp.send(null); | ||
return xmlHttp.responseText; | ||
}; | ||
return MockUtilities; | ||
}()); | ||
exports.MockUtilities = MockUtilities; |
{ | ||
"name": "angular-mock-record", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "An angular / protractor framework that mocks and records requests. Requests can be manually mocked or recorded like VCR.", | ||
@@ -5,0 +5,0 @@ "main": "server.js", |
@@ -27,4 +27,12 @@ const Utilities = require('./utilities.js'); | ||
let recording = this.isRecordingOnTape(requestUrl, tape); | ||
if (recording.length) { | ||
let recordingWithDomain = recording ? recording.find(rec => rec.domain === this.config.domain) : null; | ||
if (recording.length && !recordingWithDomain) { | ||
out = recording[0]; | ||
} else if (recordingWithDomain) { | ||
out = recordingWithDomain; | ||
} | ||
@@ -78,2 +86,6 @@ } | ||
if (this.config.domain) { | ||
data.domain = this.config.domain; | ||
} | ||
out.push(data); | ||
@@ -80,0 +92,0 @@ |
@@ -9,2 +9,3 @@ const Http = require('./http.js'); | ||
constructor(config) { | ||
this.defaultDomain = config.domain; | ||
this.config = config; | ||
@@ -29,5 +30,11 @@ this.http = new Http(this.config); | ||
} else if (this.shouldSetDomain(req.path)) { | ||
this.setDomain(req.path); | ||
res.status(200).send(true); | ||
} else if (this.shouldClearMocks(req.path)) { | ||
this.mock.clearMockedRequests(); | ||
this.setDefaultDomain(); | ||
res.status(200).send(true); | ||
@@ -94,4 +101,24 @@ | ||
shouldSetDomain(path) { | ||
return !!( path.includes('/domain/') ); | ||
} | ||
setDomain(path) { | ||
path = path.split('/'); | ||
this.config.domain = 'https://' + path[path.length - 1]; | ||
this.refreshConfigs(); | ||
} | ||
setDefaultDomain() { | ||
this.config.domain = this.defaultDomain; | ||
this.refreshConfigs(); | ||
} | ||
refreshConfigs() { | ||
this.http = new Http(this.config); | ||
this.recorder = new Record(this.config); | ||
} | ||
} | ||
module.exports = RequestHandler; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15625
412