Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browserstack-capabilities

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserstack-capabilities - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

33

index.js

@@ -63,14 +63,29 @@ var _ = require("lodash");

browserMatches = _.flatten(_.map(rules, function (rule) {
if (rule.browser_version === 'current') {
if (_.includes(['previous', 'current', 'latest'], rule.browser_version)) {
var current_rule = _.clone(rule);
delete current_rule.browser_version;
// ignore any browser with a version that can't be determined to be a number
var candidates = _.filter(browserMatches, function(browser) {
return isFinite(browser['browser_version']);
var candidates = _.filter(browserMatches, current_rule);
candidates = _.sortBy(candidates, function (browser) {
var version = browser['browser_version'];
if (isFinite(version)) {
return parseFloat(version);
} else {
return Infinity;
}
});
candidates = _.filter(candidates, current_rule);
var current = _.last(_.sortBy(candidates, function(browser) {
return parseFloat(browser['browser_version']);
}));
return current ? [current] : [];
if (rule.browser_version !== 'latest') {
candidates = _.filter(candidates, function(browser) {
return isFinite(browser['browser_version']);
});
}
var selected;
switch (rule.browser_version) {
case 'current':
case 'latest':
selected = _.nth(candidates, -1);
break;
case 'previous':
selected = _.nth(candidates, -2);
}
return selected ? [selected] : [];
}

@@ -77,0 +92,0 @@ return _.filter(browserMatches, rule);

{
"name": "browserstack-capabilities",
"version": "0.5.1",
"version": "0.6.0",
"description": "An easier way to generate multiple capabilities based on JSON filters.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -399,2 +399,134 @@ var expect = require("chai").expect;

});
describe("previous combinations", function () {
it("should take a previous browser_version include", function () {
var generatedCombo = bsCapabilities.create({
browser: "ie",
browser_version: ["previous"],
os: "Windows",
os_version: ["XP", "7"]
});
var expectedCombos = [
{
os: 'Windows',
os_version: 'XP',
browser: 'ie',
device: null,
browser_version: '6.0',
real_mobile: null
},
{
os: 'Windows',
os_version: '7',
browser: 'ie',
device: null,
browser_version: '10.0',
real_mobile: null
}
];
expect(generatedCombo).to.deep.equal(expectedCombos);
});
it("should only take operating system where browser exists", function () {
var generatedCombo = bsCapabilities.create({
browser: "edge",
browser_version: ["previous"],
os: "Windows",
os_version: ["XP", "7", "8", "8.1", "10"]
});
var expectedCombos = [
{
os: 'Windows',
os_version: '10',
browser: 'edge',
device: null,
browser_version: '17.0',
real_mobile: null
}
];
expect(generatedCombo).to.deep.equal(expectedCombos);
});
});
describe("latest combinations", function () {
it("should take a latest browser_version include", function () {
var generatedCombo = bsCapabilities.create({
browser: "ie",
browser_version: ["latest"],
os: "Windows",
os_version: ["XP", "7", "8", "8.1", "10"]
});
var expectedCombos = [
{
os: 'Windows',
os_version: 'XP',
browser: 'ie',
device: null,
browser_version: '7.0',
real_mobile: null
},
{
os: 'Windows',
os_version: '7',
browser: 'ie',
device: null,
browser_version: '11.0',
real_mobile: null
},
{
os: 'Windows',
os_version: '8',
browser: 'ie',
device: null,
browser_version: '10.0',
real_mobile: null
},
{
os: 'Windows',
os_version: '8.1',
browser: 'ie',
device: null,
browser_version: '11.0',
real_mobile: null
},
{
os: 'Windows',
os_version: '10',
browser: 'ie',
device: null,
browser_version: '11.0',
real_mobile: null
}
];
expect(generatedCombo).to.deep.equal(expectedCombos);
});
it("should only take operating system where browser exists", function () {
var generatedCombo = bsCapabilities.create({
browser: "edge",
browser_version: ["latest"],
os: "Windows",
os_version: ["XP", "7", "8", "8.1", "10"]
});
var expectedCombos = [
{
os: 'Windows',
os_version: '10',
browser: 'edge',
device: null,
browser_version: 'insider preview',
real_mobile: null
}
];
expect(generatedCombo).to.deep.equal(expectedCombos);
});
});
});
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