forked from unscrambl/browser-driver-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.spec.js
80 lines (68 loc) · 2.5 KB
/
installer.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
/* eslint-disable no-console */
const chai = require('chai');
const installer = require('./installer');
const expect = require('chai').expect;
const sinon = require('sinon');
const chaiSinon = require('chai-sinon');
const shell = require('shelljs');
const path = require('path');
chai.use(chaiSinon);
describe('browserDriverInstaller', function ()
{
const DEFAULT_TIMEOUT_IN_MILLIS = 60000;
const DRIVER_OUTPUT_PATH = './output';
this.timeout(DEFAULT_TIMEOUT_IN_MILLIS);
beforeEach(function ()
{
sinon.spy(console, 'log');
});
afterEach(function ()
{
console.log.restore();
cleanTheOutput();
});
function cleanTheOutput()
{
shell.rm('-rf', DRIVER_OUTPUT_PATH);
}
it('should not attempt to install anything if one of the path, version or both parameters are not provided',
function ()
{
expect(function () { installer.driverInstaller(); }).to.throw(
'Parameters are not valid strings.');
});
it('should throw an error if the provided version does not included in the JSON file', function ()
{
const wrongVersionNumber = '1';
expect(function ()
{
installer.driverInstaller('chrome', wrongVersionNumber,
'/some/target/path');
}).to.throw(
/Failed to locate a version of chromedriver that matches the installed version of chrome \(1\). Valid chrome versions are:*/
);
});
it('should install the chromedriver to specified path if the version is included in the JSON file',
function ()
{
return installer.driverInstaller('chrome', '54', DRIVER_OUTPUT_PATH).then(function ()
{
expect(shell.test('-e', path.resolve(DRIVER_OUTPUT_PATH, 'chromedriver'))).to.be.true;
});
});
it('should install the geckodriver to specified path if the version is included in the JSON file', function ()
{
return installer.driverInstaller('firefox', '55', DRIVER_OUTPUT_PATH).then(function ()
{
expect(shell.test('-e', path.resolve(DRIVER_OUTPUT_PATH, 'geckodriver'))).to.be.true;
});
});
it('should not install again if the wanted version is already installed', function ()
{
return installer.driverInstaller('chrome', '54', DRIVER_OUTPUT_PATH).then(function ()
{
expect(installer.driverInstaller('chrome', '54', DRIVER_OUTPUT_PATH)).to.be.false;
});
});
});