Skip to content

Commit 4268da5

Browse files
committed
Add test for non-public path
1 parent 6c7e869 commit 4268da5

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/Server.test.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("Server", function() {
3232
var instance = middleware(compiler, {
3333
stats: "errors-only",
3434
quiet: true,
35-
publicPath: "/",
35+
publicPath: "/public/",
3636
});
3737
app.use(instance);
3838
listen = listenShorthand(done);
@@ -42,59 +42,65 @@ describe("Server", function() {
4242
after(close);
4343

4444
it("GET request to bundle file", function(done) {
45-
request(app).get("/bundle.js")
45+
request(app).get("/public/bundle.js")
4646
.expect("Content-Type", "application/javascript")
4747
.expect("Content-Length", "2780")
4848
.expect("Access-Control-Allow-Origin", "*")
4949
.expect(200, /console\.log\("Hey\."\)/, done);
5050
});
5151

5252
it("POST request to bundle file", function(done) {
53-
request(app).post("/bundle.js")
53+
request(app).post("/public/bundle.js")
5454
.expect(404, done);
5555
});
5656

5757
it("request to image", function(done) {
58-
request(app).get("/svg.svg")
58+
request(app).get("/public/svg.svg")
5959
.expect("Content-Type", "image/svg+xml")
6060
.expect("Content-Length", "4778")
6161
.expect("Access-Control-Allow-Origin", "*")
6262
.expect(200, done);
6363
});
6464

6565
it("request to non existing file", function(done) {
66-
request(app).get("/nope")
66+
request(app).get("/public/nope")
6767
.expect("Content-Type", "text/html; charset=utf-8")
6868
.expect(404, done);
6969
});
7070

7171
it("request to HMR json", function(done) {
72-
request(app).get("/123a123412.hot-update.json")
72+
request(app).get("/public/123a123412.hot-update.json")
7373
.expect("Content-Type", "application/json")
7474
.expect(200, /\[\"hi\"\]/, done);
7575
});
7676

7777
it("request to directory", function(done) {
78-
request(app).get("/")
78+
request(app).get("/public/")
7979
.expect("Content-Type", "text/html")
8080
.expect("Content-Length", "10")
8181
.expect("Access-Control-Allow-Origin", "*")
8282
.expect(200, /My\ Index\./, done);
8383
});
8484

8585
it("invalid range header", function(done) {
86-
request(app).get("/svg.svg")
86+
request(app).get("/public/svg.svg")
8787
.set("Range", "bytes=6000-")
8888
.expect(416, done);
8989
});
9090

9191
it("valid range header", function(done) {
92-
request(app).get("/svg.svg")
92+
request(app).get("/public/svg.svg")
9393
.set("Range", "bytes=3000-3500")
9494
.expect("Content-Length", "501")
9595
.expect("Content-Range", "bytes 3000-3500/4778")
9696
.expect(206, done);
9797
});
98+
99+
it("request to non-public path", function(done) {
100+
request(app).get("/nonpublic/")
101+
.expect("Content-Type", "text/html; charset=utf-8")
102+
.expect(404, done);
103+
});
98104
});
99105

100106
describe("lazy mode", function() {

0 commit comments

Comments
 (0)