-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relates: #10 Co-authored-by: @akomiqaia <[email protected]>
- Loading branch information
1 parent
a061ec9
commit 2336e14
Showing
4 changed files
with
28 additions
and
7 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,10 @@ | ||
const model = require("../model"); | ||
|
||
function getPostsHandler(req,res){ | ||
console.log("wevs"); | ||
let headers = {"content-type": "application/json"} | ||
res.writeHead(200, headers); | ||
res.end(JSON.stringify(model.posts)); | ||
} | ||
|
||
module.exports = getPostsHandler; |
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
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,15 @@ | ||
const test = require("tape") | ||
const supertest = require("supertest") | ||
const test = require("tape"); | ||
const supertest = require("supertest"); | ||
const router = require("./router"); | ||
|
||
test("Test /getposts returns status 200.", t=> { | ||
supertest(router) | ||
.get("/getposts") | ||
.expect(200) | ||
.expect("content-type", "application/json") | ||
.end( (error, response) => { | ||
t.error(error); | ||
t.equal(response.text, JSON.stringify({})); | ||
t.end(); | ||
}); | ||
}); |