Skip to content

Commit

Permalink
Merge 6cbdd16 into 506dd81
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Jun 28, 2018
2 parents 506dd81 + 6cbdd16 commit f251b39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ function filterByVersion(browsers, version) {
if (start < 0) startIndex = endIndex + Number(start);
else if (start !== 'oldest') startIndex = versions.indexOf(start);

if (startIndex < 0) throw new Error(`Unable to find start version: ${start}`);
if (startIndex < 0) {
throw new Error(`Unable to find start version: ${start}`);
}
if (endIndex < 0) throw new Error(`Unable to find end version: ${end}`);

return browsers.slice(startIndex, endIndex + 1);
Expand All @@ -90,7 +92,9 @@ function transform(wanted, available) {
wanted.forEach((browser) => {
const name = browser.name.toLowerCase();

if (!available.has(name)) return;
if (!available.has(name)) {
throw new Error(`Browser ${name} is not available`);
}

let list = available.get(name).slice().sort(compare);
let platforms = browser.platform;
Expand Down
7 changes: 4 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ test('allows to retrieve all browsers on Sauce Labs', (t) => {
});
});

test('excludes browsers not available on Sauce Labs', (t) => {
sauceBrowsers([{ name: 'foo' }]).then((browsers) => {
t.deepEqual(browsers, []);
test('throws if browser is not available on Sauce Labs', (t) => {
sauceBrowsers([{ name: 'foo' }]).catch((err) => {
t.equal(err instanceof Error, true);
t.equals(err.message, 'Browser foo is not available');
t.end();
});
});
Expand Down

0 comments on commit f251b39

Please sign in to comment.