Repository navigation
Expand file tree
/
Copy pathe2e.cli.proxy.js
More file actions
128 lines (111 loc) · 3.4 KB
/
Copy pathe2e.cli.proxy.js
File metadata and controls
128 lines (111 loc) · 3.4 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"use strict";
var path = require("path");
var request = require("supertest");
var assert = require("chai").assert;
var connect = require("connect");
var browserSync = require(path.resolve("./"));
var serveStatic = require("serve-static");
var pkg = require(path.resolve("package.json"));
var cli = require(path.resolve(pkg.bin));
describe("E2E CLI proxy test", function () {
var instance, server;
before(function (done) {
browserSync.reset();
var app = connect();
app.use(serveStatic("./test/fixtures"));
server = app.listen();
var proxytarget = "http://localhost:" + server.address().port;
cli({
cli: {
input: ["start"],
flags: {
proxy: proxytarget,
open: false,
online: false,
logLevel: "silent"
}
},
cb: function (err, bs) {
instance = bs;
done();
}
});
});
after(function () {
server.close();
instance.cleanup();
});
it("serves index.html + snippet injected", function (done) {
request(instance.server)
.get("/index.html")
.set("accept", "text/html")
.expect(200)
.end(function (err, res) {
assert.include(res.text, instance.options.get("snippet"));
done();
});
});
it("serves browser-sync client js", function (done) {
request(instance.server)
.get(instance.options.getIn(["scriptPaths", "versioned"]))
.set("accept", "text/html")
.expect(200)
.end(function (err, res) {
assert.include(res.text, "Connected to BrowserSync");
done();
});
});
});
describe("E2E CLI proxy test", function () {
var instance;
before(function (done) {
browserSync.reset();
cli({
cli: {
input: ["start"],
flags: {
proxy: true, // this is: `browser-sync start --proxy`
open: false,
online: false,
logLevel: "silent"
}
},
cb: function (err, bs) {
instance = bs;
done();
}
});
});
after(function () {
instance.cleanup();
});
it("should fall back to snippet mode if no string given for proxy on cli", function () {
assert.equal(instance.options.get("mode"), "snippet");
});
});
describe("E2E CLI proxy test", function () {
var instance;
before(function (done) {
browserSync.reset();
cli({
cli: {
input: ["start"],
flags: {
proxy: "localhost:8000/path/is/here", // this is: `browser-sync start --proxy localhost:8000/path/is/here`
logLevel: "silent",
open: false
}
},
cb: function (err, bs) {
instance = bs;
done();
}
});
});
after(function () {
instance.cleanup();
});
it("promote paths in the proxy to startPath option", function () {
assert.equal(instance.options.get("startPath"), "/path/is/here");
});
});