a zip code crypto-currency system good for red ONLY

lowlevel.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. process.env.NODESASS_COV ? require('../lib-cov') : require('../lib');
  2. var assert = require('assert'),
  3. sass = require('../lib/extensions'),
  4. binding = require(sass.getBinaryPath());
  5. describe('lowlevel', function() {
  6. it('fail with options not an object', function(done) {
  7. var options = 2;
  8. assert.throws(function() {
  9. binding.renderSync(options);
  10. }, /"result" element is not an object/);
  11. done();
  12. });
  13. it('data context with options.data not provided', function(done) {
  14. var options = {
  15. /* data: */
  16. sourceComments: false,
  17. file: null,
  18. outFile: null,
  19. includePaths: '',
  20. precision: 5,
  21. sourceMap: null,
  22. style: 0,
  23. indentWidth: 2,
  24. indentType: 0,
  25. linefeed: '\n',
  26. result: { stats: {} } };
  27. binding.renderSync(options);
  28. assert(/Data context created without a source string/.test(options.result.error),
  29. 'Should fail with error message "Data context created without a source string"');
  30. done();
  31. });
  32. it('data context with both options.data and options.file not provided', function(done) {
  33. var options = {
  34. /* data: */
  35. sourceComments: false,
  36. /* file: null, */
  37. outFile: null,
  38. includePaths: '',
  39. precision: 5,
  40. sourceMap: null,
  41. style: 0,
  42. indentWidth: 2,
  43. indentType: 0,
  44. linefeed: '\n',
  45. result: { stats: {} } };
  46. binding.renderSync(options);
  47. assert(/Data context created without a source string/.test(options.result.error),
  48. 'Should fail with error message "Data context created without a source string"');
  49. done();
  50. });
  51. it('file context with both options.data and options.file not provided', function(done) {
  52. var options = {
  53. /* data: */
  54. sourceComments: false,
  55. /* file: null, */
  56. outFile: null,
  57. includePaths: '',
  58. precision: 5,
  59. sourceMap: null,
  60. style: 0,
  61. indentWidth: 2,
  62. indentType: 0,
  63. linefeed: '\n',
  64. result: { stats: {} } };
  65. binding.renderFileSync(options);
  66. assert(/File context created without an input path/.test(options.result.error),
  67. 'Should fail with error message "File context created without an input path"');
  68. done();
  69. });
  70. it('file context with options.file not provided, options.data given', function(done) {
  71. var options = {
  72. data: 'div { width: 10px; } ',
  73. sourceComments: false,
  74. /* file: null, */
  75. outFile: null,
  76. includePaths: '',
  77. precision: 5,
  78. sourceMap: null,
  79. style: 0,
  80. indentWidth: 2,
  81. indentType: 0,
  82. linefeed: '\n',
  83. result: { stats: {} } };
  84. binding.renderFileSync(options);
  85. assert(/File context created without an input path/.test(options.result.error),
  86. 'Should fail with error message "File context created without an input path"');
  87. done();
  88. });
  89. it('fail with options.result not provided', function(done) {
  90. var options = { data: 'div { width: 10px; } ',
  91. sourceComments: false,
  92. file: null,
  93. outFile: null,
  94. includePaths: '',
  95. precision: 5,
  96. sourceMap: null,
  97. style: 0,
  98. indentWidth: 2,
  99. indentType: 0,
  100. linefeed: '\n' };
  101. assert.throws(function() {
  102. binding.renderSync(options);
  103. }, /"result" element is not an object/);
  104. done();
  105. });
  106. it('fail with options.result not an object', function(done) {
  107. var options = { data: 'div { width: 10px; } ',
  108. sourceComments: false,
  109. file: null,
  110. outFile: null,
  111. includePaths: '',
  112. precision: 5,
  113. sourceMap: null,
  114. style: 0,
  115. indentWidth: 2,
  116. indentType: 0,
  117. linefeed: '\n',
  118. result: 2 };
  119. assert.throws(function() {
  120. binding.renderSync(options);
  121. }, /"result" element is not an object/);
  122. done();
  123. });
  124. it('fail with options.result.stats not provided', function(done) {
  125. var options = { data: 'div { width: 10px; } ',
  126. sourceComments: false,
  127. file: null,
  128. outFile: null,
  129. includePaths: '',
  130. precision: 5,
  131. sourceMap: null,
  132. style: 0,
  133. indentWidth: 2,
  134. indentType: 0,
  135. linefeed: '\n',
  136. result: {} };
  137. assert.throws(function() {
  138. binding.renderSync(options);
  139. }, /"result.stats" element is not an object/);
  140. done();
  141. });
  142. it('fail with options.result.stats not an object', function(done) {
  143. var options = { data: 'div { width: 10px; } ',
  144. sourceComments: false,
  145. file: null,
  146. outFile: null,
  147. includePaths: '',
  148. precision: 5,
  149. sourceMap: null,
  150. style: 0,
  151. indentWidth: 2,
  152. indentType: 0,
  153. linefeed: '\n',
  154. result: { stats: 2 } };
  155. assert.throws(function() {
  156. binding.renderSync(options);
  157. }, /"result.stats" element is not an object/);
  158. done();
  159. });
  160. it('options.indentWidth not provided', function(done) {
  161. var options = { data: 'div { width: 10px; }',
  162. sourceComments: false,
  163. file: null,
  164. outFile: null,
  165. includePaths: '',
  166. precision: 5,
  167. sourceMap: null,
  168. style: 0,
  169. /* indentWidth */
  170. indentType: 0,
  171. linefeed: '\n',
  172. result: { stats: {} } };
  173. binding.renderSync(options);
  174. assert(options.result.css);
  175. done();
  176. });
  177. it('empty data string', function(done) {
  178. var options = { data: '',
  179. sourceComments: false,
  180. file: null,
  181. outFile: null,
  182. includePaths: '',
  183. precision: 5,
  184. sourceMap: null,
  185. style: 0,
  186. /* indentWidth */
  187. indentType: 0,
  188. linefeed: '\n',
  189. result: { stats: {} } };
  190. binding.renderSync(options);
  191. assert(/empty source string/.test(options.result.error),
  192. 'Should fail with error message "Data context created with empty source string"');
  193. done();
  194. });
  195. it('empty file string', function(done) {
  196. var options = {
  197. sourceComments: false,
  198. file: '',
  199. outFile: null,
  200. includePaths: '',
  201. precision: 5,
  202. sourceMap: null,
  203. style: 0,
  204. /* indentWidth */
  205. indentType: 0,
  206. linefeed: '\n',
  207. result: { stats: {} } };
  208. binding.renderFileSync(options);
  209. assert(/empty input path/.test(options.result.error),
  210. 'Should fail with error message "File context created with empty input path"');
  211. done();
  212. });
  213. }); // lowlevel