UNPKG

3.41 kBJavaScriptView Raw
1/*eslint new-cap: ["error", {"capIsNewExceptions": ["Color"]}]*/
2
3var assert = require('assert'),
4 path = require('path'),
5 etx = require('../lib/extensions'),
6 binding = process.env.NODESASS_COV
7 ? require('../lib-cov/binding')
8 : require('../lib/binding');
9
10describe('binding', function() {
11 describe('missing error', function() {
12 it('should be useful', function() {
13 process.env.SASS_BINARY_NAME = 'unknown-x64-48';
14
15 assert.throws(
16 function() { binding(etx); },
17 function(err) {
18 var re = new RegExp('Missing binding.*?\\' + path.sep + 'vendor\\' + path.sep);
19 if ((err instanceof Error)) {
20 return re.test(err);
21 }
22 }
23 );
24 });
25
26 it('should list currently installed bindings', function() {
27 assert.throws(
28 function() { binding(etx); },
29 function(err) {
30 var etx = require('../lib/extensions');
31
32 delete process.env.SASS_BINARY_NAME;
33
34 if ((err instanceof Error)) {
35 return err.message.indexOf(
36 etx.getHumanEnvironment(etx.getBinaryName())
37 ) !== -1;
38 }
39 }
40 );
41 });
42 });
43
44 describe('on unsupported environment', function() {
45 describe('with an unsupported architecture', function() {
46 beforeEach(function() {
47 Object.defineProperty(process, 'arch', {
48 value: 'foo',
49 });
50 });
51
52 afterEach(function() {
53 Object.defineProperty(process, 'arch', {
54 value: 'x64',
55 });
56 });
57
58 it('should error', function() {
59 assert.throws(
60 function() { binding(etx); },
61 'Node Sass does not yet support your current environment'
62 );
63 });
64
65 it('should inform the user the architecture is unsupported', function() {
66 assert.throws(
67 function() { binding(etx); },
68 'Unsupported architecture (foo)'
69 );
70 });
71 });
72
73 describe('with an unsupported platform', function() {
74 beforeEach(function() {
75 Object.defineProperty(process, 'platform', {
76 value: 'bar',
77 });
78 });
79
80 afterEach(function() {
81 Object.defineProperty(process, 'platform', {
82 value: 'darwin',
83 });
84 });
85
86 it('should error', function() {
87 assert.throws(
88 function() { binding(etx); },
89 'Node Sass does not yet support your current environment'
90 );
91 });
92
93 it('should inform the user the platform is unsupported', function() {
94 assert.throws(
95 function() { binding(etx); },
96 'Unsupported platform (bar)'
97 );
98 });
99 });
100
101 describe('with an unsupported runtime', function() {
102 beforeEach(function() {
103 Object.defineProperty(process.versions, 'modules', {
104 value: 'baz',
105 });
106 });
107
108 afterEach(function() {
109 Object.defineProperty(process.versions, 'modules', {
110 value: 51,
111 });
112 });
113
114 it('should error', function() {
115 assert.throws(
116 function() { binding(etx); },
117 'Node Sass does not yet support your current environment'
118 );
119 });
120
121 it('should inform the user the runtime is unsupported', function() {
122 assert.throws(
123 function() { binding(etx); },
124 'Unsupported runtime (baz)'
125 );
126 });
127 });
128 });
129});