Repository navigation
Expand file tree
/
Copy pathcli.options.proxy.js
More file actions
77 lines (72 loc) · 2.58 KB
/
Copy pathcli.options.proxy.js
File metadata and controls
77 lines (72 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"use strict";
var cli = require("../../../lib/cli/cli-options");
var merge = cli.merge;
var assert = require("chai").assert;
describe("CLI: Options: Merging Proxy Options", function () {
var defaultValue;
beforeEach(function () {
defaultValue = false;
});
it("should merge a url with HTTP", function () {
var imm = merge({
proxy: "http://localhost:8000"
});
var out = imm.get("proxy").toJS();
assert.equal(out.target, "http://localhost:8000");
});
it("should merge a url with HTTPS", function () {
var imm = merge({
proxy: "https://localhost:8010"
});
var out = imm.get("proxy").toJS();
assert.equal(out.target, "https://localhost:8010");
});
it("should merge a url with no protocol", function () {
var imm = merge({
proxy: "localhost:8010"
});
var out = imm.get("proxy").toJS();
assert.equal(out.target, "http://localhost:8010");
});
it("should merge IP hostname", function () {
var imm = merge({
proxy: "192.168.0.4"
});
var out = imm.get("proxy").toJS();
assert.equal(out.target, "http://192.168.0.4");
});
it("should merge IP hostname with port", function () {
var imm = merge({
proxy: "192.168.0.4:9001"
});
assert.equal(imm.getIn(["proxy", "target"]), "http://192.168.0.4:9001");
assert.equal(imm.getIn(["proxy", "url", "port"]), 9001);
});
it("should merge a url with no protocol & no port", function () {
var imm = merge({
proxy: "localhost"
});
assert.equal(imm.getIn(["proxy", "url", "port"]), 80);
});
it("should merge a url with no protocol & no port", function () {
var imm = merge({
proxy: "local.dev"
});
assert.equal(imm.getIn(["proxy", "target"]), "http://local.dev");
});
describe("Setting the start path", function () {
it("should merge a url with path", function () {
var imm = merge({
proxy: "http://local.dev/subdir"
});
assert.equal(imm.getIn(["proxy", "target"]), "http://local.dev");
});
it("should merge a url with path & query params", function () {
var imm = merge({
proxy: "http://local.dev/subdir/another/path?rel=123"
});
assert.equal(imm.getIn(["proxy", "target"]), "http://local.dev");
assert.equal(imm.getIn(["proxy", "url", "port"]), 80);
});
});
});