downloadoptions.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var assert = require('assert'),
  2. ua = require('../scripts/util/useragent'),
  3. opts = require('../scripts/util/downloadoptions');
  4. describe('util', function() {
  5. describe('downloadoptions', function() {
  6. describe('without a proxy', function() {
  7. it('should look as we expect', function() {
  8. var expected = {
  9. rejectUnauthorized: false,
  10. timeout: 60000,
  11. headers: {
  12. 'User-Agent': ua(),
  13. },
  14. encoding: null,
  15. };
  16. assert.deepEqual(opts(), expected);
  17. });
  18. });
  19. describe('with an npm config proxy', function() {
  20. var proxy = 'http://test.proxy:1234';
  21. before(function() {
  22. process.env.npm_config_proxy = proxy;
  23. });
  24. after(function() {
  25. delete process.env.npm_config_proxy;
  26. });
  27. it('should look as we expect', function() {
  28. var expected = {
  29. rejectUnauthorized: false,
  30. proxy: proxy,
  31. timeout: 60000,
  32. headers: {
  33. 'User-Agent': ua(),
  34. },
  35. encoding: null,
  36. };
  37. assert.deepEqual(opts(), expected);
  38. });
  39. });
  40. describe('with an env proxy proxy', function() {
  41. var proxy = 'http://test.proxy:1234';
  42. before(function() {
  43. process.env.HTTP_PROXY = proxy;
  44. });
  45. after(function() {
  46. delete process.env.HTTP_PROXY;
  47. });
  48. it('should look as we expect', function() {
  49. var expected = {
  50. rejectUnauthorized: false,
  51. timeout: 60000,
  52. headers: {
  53. 'User-Agent': ua(),
  54. },
  55. encoding: null,
  56. };
  57. assert.deepEqual(opts(), expected);
  58. });
  59. });
  60. });
  61. });