source: trip-planner-front/node_modules/karma-chrome-launcher/test/jsflags.spec.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[6a3a178]1/* eslint-env mocha */
2
3var expect = require('chai').expect
4var sinon = require('sinon')
5
6var launcher = require('../index')
7
8describe('isJSFlags()', function () {
9 var isJSFlags = launcher.test.isJSFlags
10
11 it('should return true if flag begins with --js-flags=', function () {
12 expect(isJSFlags('--js-flags=--expose-gc')).to.be.eql(true)
13 expect(isJSFlags('--js-flags="--expose-gc"')).to.be.eql(true)
14 expect(isJSFlags("--js-flags='--expose-gc'")).to.be.eql(true)
15 })
16
17 it('should return false if flag does not begin with --js-flags=', function () {
18 expect(isJSFlags(' --js-flags=--expose-gc')).to.be.eql(false)
19 expect(isJSFlags('--js-flags"--expose-gc"')).to.be.eql(false)
20 expect(isJSFlags('--jsflags="--expose-gc"')).to.be.eql(false)
21 })
22})
23
24describe('sanitizeJSFlags()', function () {
25 var sanitizeJSFlags = launcher.test.sanitizeJSFlags
26
27 it('should do nothing if flags are not contained in quotes', function () {
28 expect(sanitizeJSFlags('--js-flags=--expose-gc')).to.be.eql('--js-flags=--expose-gc')
29 })
30
31 it('should symmetrically remove single or double quote if wraps all flags', function () {
32 expect(sanitizeJSFlags("--js-flags='--expose-gc'")).to.be.eql('--js-flags=--expose-gc')
33 expect(sanitizeJSFlags('--js-flags="--expose-gc"')).to.be.eql('--js-flags=--expose-gc')
34 })
35
36 it('should NOT remove anything if the flags are not contained within quote', function () {
37 expect(sanitizeJSFlags('--js-flags=--expose-gc="true"')).to.be.eql('--js-flags=--expose-gc="true"')
38 expect(sanitizeJSFlags("--js-flags=--expose-gc='true'")).to.be.eql("--js-flags=--expose-gc='true'")
39 })
40})
41
42describe('canaryGetOptions', function () {
43 var canaryGetOptions = launcher.test.canaryGetOptions
44
45 it('should return a merged version of --js-flags', function () {
46 var parent = sinon.stub().returns(['-incognito'])
47 var context = {}
48 var url = 'http://localhost:9876'
49 var args = { flags: ['--js-flags="--expose-gc"'] }
50 expect(canaryGetOptions.call(context, url, args, parent)).to.be.eql([
51 '-incognito',
52 '--js-flags=--expose-gc --nocrankshaft --noopt'
53 ])
54 })
55})
56
57describe('headlessGetOptions', function () {
58 var headlessGetOptions = launcher.test.headlessGetOptions
59
60 it('should return the headless flags', function () {
61 var parent = sinon.stub().returns(['-incognito'])
62 var context = {}
63 var url = 'http://localhost:9876'
64 var args = {}
65 expect(headlessGetOptions.call(context, url, args, parent)).to.be.eql([
66 '-incognito',
67 '--headless',
68 '--disable-gpu',
69 '--disable-dev-shm-usage',
70 '--remote-debugging-port=9222'
71 ])
72 })
73
74 it('should not overwrite custom remote-debugging-port', function () {
75 var parent = sinon.stub().returns(
76 ['-incognito', '--remote-debugging-port=9333']
77 )
78 var context = {}
79 var url = 'http://localhost:9876'
80 var args = {}
81 expect(headlessGetOptions.call(context, url, args, parent)).to.be.eql([
82 '-incognito',
83 '--remote-debugging-port=9333',
84 '--headless',
85 '--disable-gpu',
86 '--disable-dev-shm-usage'
87 ])
88 })
89})
Note: See TracBrowser for help on using the repository browser.