-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from fac-14/express-routes-setup
Express routes setup
- Loading branch information
Showing
18 changed files
with
229 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exports.get = (req, res) => { | ||
res.render("accepted-challenge-select", { layout: "content-selected" }); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
exports.get = (req, res) => { | ||
res.render("challSelect"); | ||
}; | ||
res.render("challSelect", { layout: "content-selected" }); | ||
}; |
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,3 @@ | ||
exports.get = (req, res) => { | ||
res.render("item-select", { layout: "content-selected" }); | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
exports.get = (req, res) => { | ||
res.render("landing"); | ||
}; | ||
res.render("landing", { layout: "logged-out" }); | ||
}; |
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,3 @@ | ||
exports.get = (req, res) => { | ||
res.render("learn"); | ||
}; |
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,3 @@ | ||
exports.get = (req, res) => { | ||
res.render("user-stats"); | ||
}; |
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,6 @@ | ||
<h2>User is viewing details of one of their accepted challenges</h2> | ||
|
||
<form action="/challenge/completed" method="POST"> | ||
<h1>Challenge completed?</h1> | ||
<button type="submit">Yes!</button> | ||
</form> |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{{!-- hello again --}} | ||
|
||
<h1>this is challange no 1</h1> | ||
<h1>this is the selected challenge</h1> | ||
|
||
<form action="/challenge/accepted" method="POST"> | ||
<h1>Accept challenge?</h1> | ||
<button type="submit">Yes!</button> | ||
</form> |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<h2>This is home dashboard where user can see their challenges</h2> | ||
|
||
<ul> | ||
<li>Item 1</li> | ||
<li>item 2</li> | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
<h2>This is where the user can view suggested zero waste items to buy</h2> | ||
|
||
<ul> | ||
<li>1</li> | ||
<li>2</li> | ||
|
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 @@ | ||
<h2>The user has selected an inventory item to learn more</h2> |
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,18 @@ | ||
{{!-- hello again --}} {{!-- this is the layout for when item is selected e.g. challenge or inventory item --}} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
{{> header}} | ||
|
||
<body> | ||
{{> navbar}} | ||
|
||
<main> | ||
<h1>Content Selected Layout!</h1> | ||
{{{body}}} | ||
</main> | ||
{{> footer}} | ||
|
||
</body> | ||
|
||
</html> |
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,18 @@ | ||
{{!-- hello again --}} {{!-- layout for when the user isn't logged in --}} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
{{> header}} | ||
|
||
<body> | ||
{{> navbar}} | ||
|
||
<main> | ||
<h1>Logged-out layout!</h1> | ||
{{{body}}} | ||
</main> | ||
{{> footer}} | ||
|
||
</body> | ||
|
||
</html> |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{{!-- hello again --}} | ||
{{!-- hello again --}} {{!-- this is the main layout for when you're logged in --}} | ||
|
||
<!DOCTYPE html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
{{> header}} | ||
{{> header}} | ||
|
||
<body> | ||
{{> navbar}} | ||
<body> | ||
{{> navbar}} | ||
|
||
<main> | ||
{{{body}}} | ||
</main> | ||
{{> footer}} | ||
<main> | ||
{{{body}}} | ||
</main> | ||
{{> footer}} | ||
|
||
</body> | ||
</body> | ||
|
||
</html> |
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 @@ | ||
<h2>This is where the user can learn about zero waste</h2> |
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 @@ | ||
<h2>This is where the user can view their stats</h2> |
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 |
---|---|---|
@@ -1,70 +1,136 @@ | ||
/* eslint-disable */ | ||
|
||
const supertest = require('supertest'); | ||
const app = require("../src/app.js") | ||
const supertest = require("supertest"); | ||
const app = require("../src/app.js"); | ||
|
||
describe("Test the root", () => { | ||
test("It should respond to the GET method", done => { | ||
supertest(app) | ||
.get('/') | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
test("It should respond to the GET method", done => { | ||
supertest(app) | ||
.get("/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the dashboard page", () => { | ||
test("Expecting a 200 status return", done =>{ | ||
supertest(app) | ||
.get('/dashboard/') | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/dashboard/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the challSelect page", () => { | ||
test("Expecting a 200 status return", done =>{ | ||
supertest(app) | ||
.get('/challSelect/') | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/challenge/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the inventory page", () => { | ||
test("Expecting a 200 status return", done =>{ | ||
supertest(app) | ||
.get('/inventory/') | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/inventory/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the learn page", () => { | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/learn/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the accepted challenge page", () => { | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/my-challenge/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the stats page", () => { | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/stats/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the inventory item page", () => { | ||
test("Expecting a 200 status return", done => { | ||
supertest(app) | ||
.get("/inventory-item/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test challenge accepted", () => { | ||
test("Expecting a 302 status return", done => { | ||
supertest(app) | ||
.post("/challenge/accepted/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(302); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test challenge completed", () => { | ||
test("Expecting a 302 status return", done => { | ||
supertest(app) | ||
.post("/challenge/completed/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(302); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test the error-route page", () => { | ||
test("Expecting a 500 status return", done =>{ | ||
supertest(app) | ||
.get('/make-error/') | ||
.then(response => { | ||
expect(response.statusCode).toBe(500); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
test("Expecting a 500 status return", done => { | ||
supertest(app) | ||
.get("/make-error/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(500); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Test an incorrect route for 404", () => { | ||
test("Expecting a 404 status return", done =>{ | ||
supertest(app) | ||
.get('/armandisgreat/') | ||
.then(response => { | ||
expect(response.statusCode).toBe(404); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
test("Expecting a 404 status return", done => { | ||
supertest(app) | ||
.get("/armandisgreat/") | ||
.then(response => { | ||
expect(response.statusCode).toBe(404); | ||
done(); | ||
}); | ||
}); | ||
}); |