Skip to content

Commit

Permalink
Make binding tests less fragile
Browse files Browse the repository at this point in the history
Use hardcoded process values rather than inspecting the current
environment.
  • Loading branch information
xzyfer committed Mar 21, 2017
1 parent 10f9a58 commit 7488f55
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions test/binding.js
Expand Up @@ -10,7 +10,8 @@ var assert = require('assert'),
describe('binding', function() {
describe('missing error', function() {
it('should be useful', function() {
process.env.SASS_BINARY_NAME = 'Linux-x64-48';
process.env.SASS_BINARY_NAME = 'unknown-x64-48';

assert.throws(
function() { binding(etx); },
function(err) {
Expand Down Expand Up @@ -42,19 +43,15 @@ describe('binding', function() {

describe('on unsupported environment', function() {
describe('with an unsupported architecture', function() {
var prevValue;

beforeEach(function() {
prevValue = process.arch;

Object.defineProperty(process, 'arch', {
value: 'foo',
});
});

afterEach(function() {
Object.defineProperty(process, 'arch', {
value: prevValue,
value: 'x64',
});
});

Expand All @@ -74,19 +71,15 @@ describe('binding', function() {
});

describe('with an unsupported platform', function() {
var prevValue;

beforeEach(function() {
prevValue = process.platform;

Object.defineProperty(process, 'platform', {
value: 'bar',
});
});

afterEach(function() {
Object.defineProperty(process, 'platform', {
value: prevValue,
value: 'darwin',
});
});

Expand All @@ -106,19 +99,15 @@ describe('binding', function() {
});

describe('with an unsupported runtime', function() {
var prevValue;

beforeEach(function() {
prevValue = process.versions.modules;

Object.defineProperty(process.versions, 'modules', {
value: 'baz',
});
});

afterEach(function() {
Object.defineProperty(process.versions, 'modules', {
value: prevValue,
value: 51,
});
});

Expand Down

0 comments on commit 7488f55

Please sign in to comment.