Refactor public pages test
This commit is contained in:
parent
43227d42ad
commit
433eef2292
1 changed files with 28 additions and 93 deletions
121
test/pages.js
121
test/pages.js
|
@ -51,100 +51,35 @@ describe("Pages tests", () => {
|
||||||
return clean;
|
return clean;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Responds to /", (done) => {
|
for (let [url, code] of Object.entries({
|
||||||
request(app)
|
"/": 200,
|
||||||
.get("/")
|
"/login": 200,
|
||||||
.expect(200, done);
|
"/forget": 200,
|
||||||
});
|
"/register": 200,
|
||||||
it("Responds to /login", (done) => {
|
"/check": 400,
|
||||||
request(app)
|
"/logout": 302,
|
||||||
.get("/login")
|
"/profile": 302,
|
||||||
.expect(200, done);
|
"/sandwiches": 302,
|
||||||
});
|
"/orders": 302,
|
||||||
it("Responds to /forget", (done) => {
|
"/admin": 302,
|
||||||
request(app)
|
"/admin/orders": 302,
|
||||||
.get("/forget")
|
"/admin/orders/date": 302,
|
||||||
.expect(200, done)
|
"/admin/sandwiches": 302,
|
||||||
});
|
"/admin/sandwiches/add": 302,
|
||||||
it("Responds to /register", (done) => {
|
"/admin/sandwiches/edit": 302,
|
||||||
request(app)
|
"/admin/departments": 302,
|
||||||
.get("/register")
|
"/admin/departments/add": 302,
|
||||||
.expect(200, done);
|
"/admin/departments/edit": 302,
|
||||||
});
|
}))
|
||||||
it("Responds to /check", (done) => {
|
it("Responds to "+url, async () => {
|
||||||
request(app)
|
await request(app)
|
||||||
.get("/check")
|
.get(url)
|
||||||
.expect(400, done);
|
.expect(code);
|
||||||
});
|
});
|
||||||
it("Responds to /logout", (done) => {
|
it("404 everything else", async () => {
|
||||||
request(app)
|
await request(app)
|
||||||
.get("/logout")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Response to /profile", (done) => {
|
|
||||||
request(app)
|
|
||||||
.get("/profile")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Response to /sandwiches", (done) => {
|
|
||||||
request(app)
|
|
||||||
.get("/sandwiches")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Response to /orders", (done) => {
|
|
||||||
request(app)
|
|
||||||
.get("/orders")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Response to /admin", (done) => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Response to /admin/orders", (done) => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/orders")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Response to /admin/orders/date", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/orders/date")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Reponse to /admin/sandwiches", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/sandwiches")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Reponse to /admin/sandwiches/add", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/sandwiches/add")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Reponse to /admin/sandwiches/edit", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/sandwiches/edit")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Reponse to /admin/departments", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/departments")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Reponse to /admin/departments/add", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/departments/add")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("Reponse to /admin/departments/edit", done => {
|
|
||||||
request(app)
|
|
||||||
.get("/admin/departments/edit")
|
|
||||||
.expect(302, done);
|
|
||||||
});
|
|
||||||
it("404 everything else", (done) => {
|
|
||||||
request(app)
|
|
||||||
.get("/foo/bar")
|
.get("/foo/bar")
|
||||||
.expect(404, done);
|
.expect(404);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Reference in a new issue