mirror of
https://github.com/microsoft/TypeScript-Node-Starter.git
synced 2025-11-08 20:27:37 +00:00
coverage/chai support and some unit tests
1. added jest coverage support (#64) 2. added chai testing support 3. created new unit tests
This commit is contained in:
committed by
Bowden Kelly
parent
780e30826c
commit
d080f39b86
@@ -1,9 +1,27 @@
|
||||
import * as request from "supertest";
|
||||
import * as app from "../src/app";
|
||||
|
||||
var chai = require('chai');
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("GET /contact", () => {
|
||||
it("should return 200 OK", (done) => {
|
||||
request(app).get("/contact")
|
||||
.expect(200, done);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("POST /contact", () => {
|
||||
it("should return false from assert when no message is found", (done) => {
|
||||
request(app).post("/contact")
|
||||
.field("name", "John Doe")
|
||||
.field("email", "john@me.com")
|
||||
.end(function(err, res) {
|
||||
expect(res.error).to.be.false;
|
||||
done();
|
||||
})
|
||||
.expect(302);
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,9 @@
|
||||
import * as request from "supertest";
|
||||
import * as app from "../src/app";
|
||||
|
||||
var chai = require('chai');
|
||||
var expect = chai.expect;
|
||||
|
||||
describe("GET /login", () => {
|
||||
it("should return 200 OK", () => {
|
||||
return request(app).get("/login")
|
||||
@@ -14,3 +17,18 @@ describe("GET /signup", () => {
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe("POST /login", () => {
|
||||
it("should return some defined error message with valid parameters", (done) => {
|
||||
return request(app).post("/login")
|
||||
.field("email", "john@me.com")
|
||||
.field("password", "Hunter2")
|
||||
.expect(302)
|
||||
.end(function(err, res) {
|
||||
expect(res.error).not.to.be.undefined;
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user