a zip code crypto-currency system good for red ONLY

runtime.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. var assert = require('assert'),
  2. sass = process.env.NODESASS_COV
  3. ? require('../lib-cov/extensions')
  4. : require('../lib/extensions');
  5. describe('runtime parameters', function() {
  6. var pkg = require('../package'),
  7. // Let's use JSON to fake a deep copy
  8. savedArgv = JSON.stringify(process.argv),
  9. savedEnv = JSON.stringify(process.env);
  10. afterEach(function() {
  11. process.argv = JSON.parse(savedArgv);
  12. process.env = JSON.parse(savedEnv);
  13. delete pkg.nodeSassConfig;
  14. });
  15. describe('configuration precedence should be respected', function() {
  16. describe('SASS_BINARY_NAME', function() {
  17. beforeEach(function() {
  18. process.argv.push('--sass-binary-name', 'aaa');
  19. process.env.SASS_BINARY_NAME = 'bbb';
  20. process.env.npm_config_sass_binary_name = 'ccc';
  21. pkg.nodeSassConfig = { binaryName: 'ddd' };
  22. });
  23. it('command line argument', function() {
  24. assert.equal(sass.getBinaryName(), 'aaa_binding.node');
  25. });
  26. it('environment variable', function() {
  27. process.argv = [];
  28. assert.equal(sass.getBinaryName(), 'bbb_binding.node');
  29. });
  30. it('npm config variable', function() {
  31. process.argv = [];
  32. process.env.SASS_BINARY_NAME = null;
  33. assert.equal(sass.getBinaryName(), 'ccc_binding.node');
  34. });
  35. it('package.json', function() {
  36. process.argv = [];
  37. process.env.SASS_BINARY_NAME = null;
  38. process.env.npm_config_sass_binary_name = null;
  39. assert.equal(sass.getBinaryName(), 'ddd_binding.node');
  40. });
  41. });
  42. describe('SASS_BINARY_SITE', function() {
  43. beforeEach(function() {
  44. process.argv.push('--sass-binary-site', 'http://aaa.example.com:9999');
  45. process.env.SASS_BINARY_SITE = 'http://bbb.example.com:8888';
  46. process.env.npm_config_sass_binary_site = 'http://ccc.example.com:7777';
  47. pkg.nodeSassConfig = { binarySite: 'http://ddd.example.com:6666' };
  48. });
  49. it('command line argument', function() {
  50. var URL = 'http://aaa.example.com:9999';
  51. assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
  52. });
  53. it('environment variable', function() {
  54. process.argv = [];
  55. var URL = 'http://bbb.example.com:8888';
  56. assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
  57. });
  58. it('npm config variable', function() {
  59. process.argv = [];
  60. process.env.SASS_BINARY_SITE = null;
  61. var URL = 'http://ccc.example.com:7777';
  62. assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
  63. });
  64. it('package.json', function() {
  65. process.argv = [];
  66. process.env.SASS_BINARY_SITE = null;
  67. process.env.npm_config_sass_binary_site = null;
  68. var URL = 'http://ddd.example.com:6666';
  69. assert.equal(sass.getBinaryUrl().substr(0, URL.length), URL);
  70. });
  71. });
  72. describe('SASS_BINARY_DIR', function() {
  73. beforeEach(function() {
  74. process.argv.push('--sass-binary-dir', 'aaa');
  75. process.env.SASS_BINARY_DIR = 'bbb';
  76. process.env.npm_config_sass_binary_dir = 'ccc';
  77. pkg.nodeSassConfig = { binaryDir: 'ddd' };
  78. });
  79. it('command line argument', function() {
  80. assert.equal(sass.getBinaryDir(), 'aaa');
  81. });
  82. it('environment variable', function() {
  83. process.argv = [];
  84. assert.equal(sass.getBinaryDir(), 'bbb');
  85. });
  86. it('npm config variable', function() {
  87. process.argv = [];
  88. process.env.SASS_BINARY_DIR = null;
  89. assert.equal(sass.getBinaryDir(), 'ccc');
  90. });
  91. it('package.json', function() {
  92. process.argv = [];
  93. process.env.SASS_BINARY_DIR = null;
  94. process.env.npm_config_sass_binary_dir = null;
  95. assert.equal(sass.getBinaryDir(), 'ddd');
  96. });
  97. });
  98. describe('SASS_BINARY_PATH', function() {
  99. beforeEach(function() {
  100. process.argv.push('--sass-binary-path', 'aaa_binding.node');
  101. process.env.SASS_BINARY_PATH = 'bbb_binding.node';
  102. process.env.npm_config_sass_binary_path = 'ccc_binding.node';
  103. pkg.nodeSassConfig = { binaryPath: 'ddd_binding.node' };
  104. });
  105. it('command line argument', function() {
  106. assert.equal(sass.getBinaryPath(), 'aaa_binding.node');
  107. });
  108. it('environment variable', function() {
  109. process.argv = [];
  110. assert.equal(sass.getBinaryPath(), 'bbb_binding.node');
  111. });
  112. it('npm config variable', function() {
  113. process.argv = [];
  114. process.env.SASS_BINARY_PATH = null;
  115. assert.equal(sass.getBinaryPath(), 'ccc_binding.node');
  116. });
  117. it('package.json', function() {
  118. process.argv = [];
  119. process.env.SASS_BINARY_PATH = null;
  120. process.env.npm_config_sass_binary_path = null;
  121. assert.equal(sass.getBinaryPath(), 'ddd_binding.node');
  122. });
  123. });
  124. });
  125. describe.skip('Sass Binary Cache', function() {
  126. var npmCacheDir;
  127. before(function() {
  128. npmCacheDir = process.env.npm_config_cache;
  129. });
  130. beforeEach(function() {
  131. delete process.env.npm_config_sass_binary_cache;
  132. });
  133. it('npm config variable', function() {
  134. var overridenCachePath = '/foo/bar/';
  135. process.env.npm_config_sass_binary_cache = overridenCachePath;
  136. assert.equal(sass.getCachePath(), overridenCachePath);
  137. });
  138. it('With no value, falls back to NPM cache', function() {
  139. assert.equal(sass.getCachePath(), npmCacheDir);
  140. });
  141. });
  142. });
  143. // describe('library detection', function() {
  144. // it('should throw error when libsass binary is missing.', function() {
  145. // var sass = require(extensionsPath),
  146. // originalBin = sass.getBinaryPath(),
  147. // renamedBin = [originalBin, '_moved'].join('');
  148. // assert.throws(function() {
  149. // fs.renameSync(originalBin, renamedBin);
  150. // sass.getBinaryPath(true);
  151. // }, /The `libsass` binding was not found/);
  152. // fs.renameSync(renamedBin, originalBin);
  153. // });
  154. // });