UNPKG

2.52 kBJavaScriptView Raw
1var path = require('path')
2var di = require('di')
3var mocks = require('mocks')
4var osHomedir = require('os-homedir')
5
6describe('launcher', function () {
7 var EventEmitter, EdgeLauncher, injector, launcher, module
8
9 beforeEach(function () {
10 EventEmitter = require('../node_modules/karma/lib/events').EventEmitter
11 EdgeLauncher = mocks.loadFile(path.join(__dirname, '/../index')).module.exports
12 module = {
13 baseBrowserDecorator: ['value', function () {}],
14 emitter: ['value', new EventEmitter()],
15 logger: [
16 'value', {
17 create: function () {
18 return {
19 error: function () {},
20 debug: function () {}
21 }
22 }
23 }
24 ],
25 args: ['value', []]
26 }
27 })
28
29 afterEach(function () {
30 injector = null
31 launcher = null
32 })
33
34 describe('exports', function () {
35 it('should export launcher:Edge', function (done) {
36 expect(EdgeLauncher['launcher:Edge']).to.defined
37 done()
38 })
39 })
40
41 describe('initialization', function () {
42 // These tests run from the home directory to ensure that the launcher is
43 // initialized properly regardless of the working directory
44
45 var previousdir
46
47 before(function () {
48 previousdir = process.cwd()
49 process.chdir(osHomedir())
50 })
51
52 after(function () {
53 process.chdir(previousdir)
54 })
55
56 beforeEach(function () {
57 injector = new di.Injector([module, EdgeLauncher])
58 launcher = injector.get('launcher:Edge')
59 })
60
61 it('should initialize name', function (done) {
62 expect(launcher.name).to.equal('Edge')
63 done()
64 })
65
66 it('should initialize ENV_CMD', function (done) {
67 expect(launcher.ENV_CMD).to.equal('EDGE_BIN')
68 done()
69 })
70
71 it('should initialize DEFAULT_CMD.win32', function (done) {
72 expect(launcher.DEFAULT_CMD.win32).to.be.a.file()
73 done()
74 })
75 })
76
77 describe('_getOptions', function () {
78 var getOptions
79
80 beforeEach(function () {
81 getOptions = function (url, module) {
82 injector = new di.Injector([module, EdgeLauncher])
83 launcher = injector.get('launcher:Edge')
84 return launcher._getOptions('url')
85 }
86 })
87
88 it('should return the given URL and a keepalive flag for launching Edge', function (done) {
89 var options = getOptions('url', module)
90 expect(options).to.deep.equal(['url', '-k'])
91 done()
92 })
93 })
94})