1 | const { expect } = require('chai')
|
2 |
|
3 | const Xvfb = require('../')
|
4 |
|
5 | describe('xvfb', function () {
|
6 | context('onStderrData', function () {
|
7 | it('accepts callback function', function () {
|
8 | const cb = () => {}
|
9 |
|
10 | const xvfb = new Xvfb({
|
11 | onStderrData: cb,
|
12 | })
|
13 |
|
14 | expect(xvfb._onStderrData).to.eq(cb)
|
15 | })
|
16 |
|
17 | it('sets default function otherwise', function () {
|
18 | const xvfb = new Xvfb()
|
19 |
|
20 | expect(xvfb._onStderrData).to.be.a('function')
|
21 | })
|
22 | })
|
23 |
|
24 | context('issue: #1', function () {
|
25 | beforeEach(function () {
|
26 | this.xvfb = new Xvfb()
|
27 | })
|
28 |
|
29 | it('issue #1: does not mutate process.env.DISPLAY', function () {
|
30 | delete process.env.DISPLAY
|
31 |
|
32 | expect(process.env.DISPLAY).to.be.undefined
|
33 |
|
34 | this.xvfb._setDisplayEnvVariable()
|
35 | this.xvfb._restoreDisplayEnvVariable()
|
36 |
|
37 | expect(process.env.DISPLAY).to.be.undefined
|
38 | })
|
39 | })
|
40 | })
|