-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): set index correctly if serveStaticOptions: {index: <path…
…>} given
- Loading branch information
1 parent
182832e
commit 34816a7
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
"use strict"; | ||
|
||
var browserSync = require("../../../../index"); | ||
var request = require("supertest"); | ||
var assert = require("chai").assert; | ||
|
||
describe("E2E server test with serve static options", function () { | ||
|
||
it("sets the index of serve-static", function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
var config = { | ||
server: { | ||
baseDir: "test/fixtures", | ||
serveStaticOptions: { | ||
index: "inputs.html" | ||
} | ||
}, | ||
logLevel: "silent", | ||
open: false | ||
}; | ||
|
||
browserSync.create().init(config, function (err, bs) { | ||
assert.equal(bs.options.getIn(["server", "serveStaticOptions", "index"]), "inputs.html"); | ||
request(bs.server) | ||
.get("/") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.deepEqual( | ||
require("fs").readFileSync("test/fixtures/inputs.html", "utf-8"), | ||
res.text | ||
); | ||
bs.cleanup(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it("sets uses the default for serve static index", function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
var config = { | ||
server: { | ||
baseDir: "test/fixtures", | ||
serveStaticOptions: {} | ||
}, | ||
logLevel: "silent", | ||
open: false | ||
}; | ||
|
||
browserSync.create().init(config, function (err, bs) { | ||
assert.equal(bs.options.getIn(["server", "serveStaticOptions", "index"]), "index.html"); | ||
request(bs.server) | ||
.get("/") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.deepEqual( | ||
require("fs").readFileSync("test/fixtures/index.html", "utf-8"), | ||
res.text | ||
); | ||
bs.cleanup(); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |