1 process.env.NODESASS_COV ? require('../lib-cov') : require('../lib');
3 var assert = require('assert'),
4 sass = require('../lib/extensions'),
5 binding = require(sass.getBinaryPath());
7 describe('lowlevel', function() {
8 it('fail with options not an object', function(done) {
10 assert.throws(function() {
11 binding.renderSync(options);
12 }, /"result" element is not an object/);
16 it('data context with options.data not provided', function(done) {
19 sourceComments: false,
29 result: { stats: {} } };
31 binding.renderSync(options);
32 assert(/Data context created without a source string/.test(options.result.error),
33 'Should fail with error message "Data context created without a source string"');
37 it('data context with both options.data and options.file not provided', function(done) {
40 sourceComments: false,
50 result: { stats: {} } };
52 binding.renderSync(options);
53 assert(/Data context created without a source string/.test(options.result.error),
54 'Should fail with error message "Data context created without a source string"');
58 it('file context with both options.data and options.file not provided', function(done) {
61 sourceComments: false,
71 result: { stats: {} } };
73 binding.renderFileSync(options);
74 assert(/File context created without an input path/.test(options.result.error),
75 'Should fail with error message "File context created without an input path"');
79 it('file context with options.file not provided, options.data given', function(done) {
81 data: 'div { width: 10px; } ',
82 sourceComments: false,
92 result: { stats: {} } };
94 binding.renderFileSync(options);
95 assert(/File context created without an input path/.test(options.result.error),
96 'Should fail with error message "File context created without an input path"');
100 it('fail with options.result not provided', function(done) {
101 var options = { data: 'div { width: 10px; } ',
102 sourceComments: false,
113 assert.throws(function() {
114 binding.renderSync(options);
115 }, /"result" element is not an object/);
120 it('fail with options.result not an object', function(done) {
121 var options = { data: 'div { width: 10px; } ',
122 sourceComments: false,
134 assert.throws(function() {
135 binding.renderSync(options);
136 }, /"result" element is not an object/);
141 it('fail with options.result.stats not provided', function(done) {
143 var options = { data: 'div { width: 10px; } ',
144 sourceComments: false,
156 assert.throws(function() {
157 binding.renderSync(options);
158 }, /"result.stats" element is not an object/);
162 it('fail with options.result.stats not an object', function(done) {
164 var options = { data: 'div { width: 10px; } ',
165 sourceComments: false,
175 result: { stats: 2 } };
177 assert.throws(function() {
178 binding.renderSync(options);
179 }, /"result.stats" element is not an object/);
183 it('options.indentWidth not provided', function(done) {
184 var options = { data: 'div { width: 10px; }',
185 sourceComments: false,
195 result: { stats: {} } };
197 binding.renderSync(options);
198 assert(options.result.css);
202 it('empty data string', function(done) {
203 var options = { data: '',
204 sourceComments: false,
214 result: { stats: {} } };
216 binding.renderSync(options);
217 assert(/empty source string/.test(options.result.error),
218 'Should fail with error message "Data context created with empty source string"');
223 it('empty file string', function(done) {
225 sourceComments: false,
235 result: { stats: {} } };
237 binding.renderFileSync(options);
238 assert(/empty input path/.test(options.result.error),
239 'Should fail with error message "File context created with empty input path"');