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