123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- /*eslint new-cap: ["error", {"capIsNewExceptions": ["Color"]}]*/
- var assert = require('assert'),
- path = require('path'),
- etx = require('../lib/extensions'),
- binding = process.env.NODESASS_COV
- ? require('../lib-cov/binding')
- : require('../lib/binding');
- describe('binding', function() {
- describe('missing error', function() {
- it('should be useful', function() {
- process.env.SASS_BINARY_NAME = 'Linux-x64-48';
- assert.throws(
- function() { binding(etx); },
- function(err) {
- var re = new RegExp('Missing binding.*?\\' + path.sep + 'vendor\\' + path.sep);
- if ((err instanceof Error)) {
- return re.test(err);
- }
- }
- );
- });
- it('should list currently installed bindings', function() {
- assert.throws(
- function() { binding(etx); },
- function(err) {
- var etx = require('../lib/extensions');
- delete process.env.SASS_BINARY_NAME;
- if ((err instanceof Error)) {
- return err.message.indexOf(
- etx.getHumanEnvironment(etx.getBinaryName())
- ) !== -1;
- }
- }
- );
- });
- });
- 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,
- });
- });
- it('should error', function() {
- assert.throws(
- function() { binding(etx); },
- 'Node Sass does not yet support your current environment'
- );
- });
- it('should inform the user the architecture is unsupported', function() {
- assert.throws(
- function() { binding(etx); },
- 'Unsupported architecture (foo)'
- );
- });
- });
- 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,
- });
- });
- it('should error', function() {
- assert.throws(
- function() { binding(etx); },
- 'Node Sass does not yet support your current environment'
- );
- });
- it('should inform the user the platform is unsupported', function() {
- assert.throws(
- function() { binding(etx); },
- 'Unsupported platform (bar)'
- );
- });
- });
- 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,
- });
- });
- it('should error', function() {
- assert.throws(
- function() { binding(etx); },
- 'Node Sass does not yet support your current environment'
- );
- });
- it('should inform the user the runtime is unsupported', function() {
- assert.throws(
- function() { binding(etx); },
- 'Unsupported runtime (baz)'
- );
- });
- });
- });
- });
|