Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test: add spec for MacOS
  • Loading branch information
codebytere committed Dec 22, 2018
1 parent feeda28 commit 7de2451
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
35 changes: 18 additions & 17 deletions spec/api-shell-spec.js
Expand Up @@ -19,8 +19,8 @@ describe('shell module', () => {
describe('shell.openExternal()', () => {
let envVars = {}

beforeEach(() => {
// keep original process.env values to prevent side effect
beforeEach(function () {
if (process.platform === 'win32') this.skip()
envVars = {
display: process.env.DISPLAY,
de: process.env.DE,
Expand All @@ -29,31 +29,32 @@ describe('shell module', () => {
})

afterEach(() => {
process.env.BROWSER = envVars.browser
process.env.DE = envVars.de
process.env.DISPLAY = envVars.display
// reset env vars to prevent side effects
if (process.platform === 'linux') {
process.env.DE = envVars.de
process.env.BROWSER = envVars.browser
process.env.DISPLAY = envVars.display
}
})

it('opens an external link asynchronously', function (done) {
if (process.platform !== 'linux') this.skip()

// set env vars for xdg-open
const url = 'http://www.example.com'
process.env.DE = 'generic'
process.env.BROWSER = '/bin/true'
process.env.DISPLAY = ''
if (process.platform === 'linux') {
process.env.BROWSER = '/bin/true'
process.env.DE = 'generic'
process.env.DISPLAY = ''
}

shell.openExternal(url).then(() => done())
})

it('opens an external link synchronously', function () {
if (process.platform !== 'linux') this.skip()

// set env vars for xdg-open
const url = 'http://www.example.com'
process.env.DE = 'generic'
process.env.BROWSER = '/bin/true'
process.env.DISPLAY = ''
if (process.platform === 'linux') {
process.env.DE = 'generic'
process.env.DE = '/bin/true'
process.env.DISPLAY = ''
}

const success = shell.openExternalSync(url)
assert.strictEqual(true, success)
Expand Down
32 changes: 16 additions & 16 deletions spec/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7de2451

Please sign in to comment.