-
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.
tests: more e2e tests for live updating rewrite rules
- Loading branch information
1 parent
bf0c4f7
commit d3fff5c
Showing
3 changed files
with
112 additions
and
4 deletions.
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,49 @@ | ||
"use strict"; | ||
|
||
var browserSync = require("../../../../index"); | ||
|
||
var request = require("supertest"); | ||
var assert = require("chai").assert; | ||
|
||
describe("E2E server test with rewrite rules added on the fly", function () { | ||
|
||
var bs; | ||
|
||
before(function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
var config = { | ||
server: { | ||
baseDir: "test/fixtures" | ||
}, | ||
logLevel: "silent", | ||
open: false | ||
}; | ||
|
||
bs = browserSync.init(config, done).instance; | ||
}); | ||
|
||
after(function () { | ||
bs.cleanup(); | ||
}); | ||
|
||
it("serves files with HTML rewritten", function (done) { | ||
|
||
bs.addRewriteRule({ | ||
match: /Forms/g, | ||
fn: function () { | ||
return "Shane's forms"; | ||
} | ||
}); | ||
|
||
request(bs.server) | ||
.get("/index.html") | ||
.set("accept", "text/html") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.include(res.text, "Shane's forms"); | ||
done(); | ||
}); | ||
}); | ||
}); |
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,61 @@ | ||
"use strict"; | ||
|
||
var browserSync = require("../../../../index"); | ||
|
||
var request = require("supertest"); | ||
var assert = require("chai").assert; | ||
|
||
describe("E2E server test with rewrite rules removed on the fly", function () { | ||
|
||
var bs; | ||
|
||
before(function (done) { | ||
|
||
browserSync.reset(); | ||
|
||
var config = { | ||
server: { | ||
baseDir: "test/fixtures" | ||
}, | ||
logLevel: "silent", | ||
open: false | ||
}; | ||
|
||
bs = browserSync.init(config, done).instance; | ||
}); | ||
|
||
after(function () { | ||
bs.cleanup(); | ||
}); | ||
|
||
it("serves files with HTML rewritten", function (done) { | ||
|
||
bs.addRewriteRule({ | ||
id: "myrule", | ||
match: /Forms/g, | ||
fn: function () { | ||
return "Shane's forms"; | ||
} | ||
}); | ||
|
||
request(bs.server) | ||
.get("/index.html") | ||
.set("accept", "text/html") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.include(res.text, "Shane's forms"); | ||
|
||
bs.removeRewriteRule("myrule"); | ||
|
||
request(bs.server) | ||
.get("/index.html") | ||
.set("accept", "text/html") | ||
.expect(200) | ||
.end(function (err, res) { | ||
assert.notInclude(res.text, "Shane's forms"); | ||
done(); | ||
}); | ||
|
||
}); | ||
}); | ||
}); |