New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-mock-record

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-mock-record - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

10

client/mock.utilities.js

@@ -53,2 +53,12 @@ Object.defineProperty(exports, "__esModule", { value: true });

};
MockUtilities.prototype.setContext = function (context) {
browser.executeScript(this.setContextRequest(context));
};
MockUtilities.prototype.setContextRequest = function (context) {
var url = this.api_host + '/context/' + context;
var xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', url, false);
xmlHttp.send(null);
return xmlHttp.responseText;
};
MockUtilities.prototype.login = function (user) {

@@ -55,0 +65,0 @@ browser.executeScript(this.loginRequest(user));

2

package.json
{
"name": "angular-mock-record",
"version": "1.4.1",
"version": "1.5.0",
"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",

@@ -28,11 +28,26 @@ const Utilities = require('./utilities.js');

let recordingWithDomain = recording ? recording.find(rec => rec.domain === this.config.domain) : null;
let recordingWithContext = recording ? recording.find(rec => rec.context === this.config.context) : null;
let shouldCheckContext = this.config.context;
if (recording.length && !recordingWithDomain) {
if (recording.length) {
out = recording[0];
// If no context or domain, use the first
if (!recordingWithDomain && !shouldCheckContext) {
} else if (recordingWithDomain) {
out = recording[0];
// If no context and domain, use the domain recording
} else if (!shouldCheckContext && recordingWithDomain) {
out = recordingWithDomain;
out = recordingWithDomain;
}
// Lastly record a context-specific recording if context enabled
if (shouldCheckContext && recordingWithContext) {
out = recordingWithContext;
}
}

@@ -90,2 +105,6 @@ }

if (this.config.context) {
data.context = this.config.context;
}
out.push(data);

@@ -92,0 +111,0 @@

@@ -11,2 +11,3 @@ const Http = require('./http.js');

this.defaultDomain = config.domain;
this.defaultContext = null;
this.config = config;

@@ -38,2 +39,7 @@ this.http = new Http(this.config);

} else if (this.shouldSetContext(req.path)) {
this.setContext(req.path);
res.status(200).send(true);
} else if (this.shouldClearMocks(req.path)) {

@@ -44,2 +50,3 @@

this.setDefaultDomain();
this.setDefaultContext();
res.status(200).send(true);

@@ -119,2 +126,6 @@

}
shouldSetContext(path) {
return !!( path.includes('/context/') );
}

@@ -126,2 +137,8 @@ refreshConfigs() {

setContext(path) {
path = path.split('/');
this.config.context = path[2];
this.refreshConfigs();
}
setDomain(path) {

@@ -138,4 +155,9 @@ path = path.split('/');

setDefaultContext() {
this.config.context = this.defaultContext;
this.refreshConfigs();
}
}
module.exports = RequestHandler;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc