downloadoptions.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. };
  15. assert.deepEqual(opts(), expected);
  16. });
  17. });
  18. describe('with an npm config proxy', function() {
  19. var proxy = 'http://test.proxy:1234';
  20. before(function() {
  21. process.env.npm_config_proxy = proxy;
  22. });
  23. after(function() {
  24. delete process.env.npm_config_proxy;
  25. });
  26. it('should look as we expect', function() {
  27. var expected = {
  28. rejectUnauthorized: false,
  29. proxy: proxy,
  30. timeout: 60000,
  31. headers: {
  32. 'User-Agent': ua(),
  33. }
  34. };
  35. assert.deepEqual(opts(), expected);
  36. });
  37. });
  38. describe('with an env proxy proxy', function() {
  39. var proxy = 'http://test.proxy:1234';
  40. before(function() {
  41. process.env.HTTP_PROXY = proxy;
  42. });
  43. after(function() {
  44. delete process.env.HTTP_PROXY;
  45. });
  46. it('should look as we expect', function() {
  47. var expected = {
  48. rejectUnauthorized: false,
  49. timeout: 60000,
  50. headers: {
  51. 'User-Agent': ua(),
  52. }
  53. };
  54. assert.deepEqual(opts(), expected);
  55. });
  56. });
  57. });
  58. });