UNPKG

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