errors.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var assert = require('assert').strict,
  2. path = require('path'),
  3. errors = require('../lib/errors');
  4. describe('binary errors', function() {
  5. function getCurrentPlatform() {
  6. if (process.platform === 'win32') {
  7. return 'Windows';
  8. } else if (process.platform === 'darwin') {
  9. return 'OS X';
  10. }
  11. return '';
  12. }
  13. function getCurrentArchitecture() {
  14. if (process.arch === 'x86' || process.arch === 'ia32') {
  15. return '32-bit';
  16. } else if (process.arch === 'x64') {
  17. return '64-bit';
  18. }
  19. return '';
  20. }
  21. function getCurrentEnvironment() {
  22. return getCurrentPlatform() + ' ' + getCurrentArchitecture();
  23. }
  24. describe('for an unsupported environment', function() {
  25. it('identifies the current environment', function() {
  26. var message = errors.unsupportedEnvironment();
  27. assert.ok(message.indexOf(getCurrentEnvironment()) !== -1);
  28. });
  29. it('links to supported environment documentation', function() {
  30. var message = errors.unsupportedEnvironment();
  31. assert.ok(message.indexOf('https://github.com/sass/node-sass/releases/tag/v') !== -1);
  32. });
  33. });
  34. describe('for an missing binary', function() {
  35. it('identifies the current environment', function() {
  36. var message = errors.missingBinary();
  37. assert.ok(message.indexOf(getCurrentEnvironment()) !== -1);
  38. });
  39. it('documents the expected binary location', function() {
  40. var message = errors.missingBinary();
  41. assert.ok(message.indexOf(path.sep + 'vendor' + path.sep) !== -1);
  42. });
  43. });
  44. });