update README with test instructions
This commit is contained in:
Родитель
0d3700dfed
Коммит
eeb3c24214
16
README.md
16
README.md
|
@ -109,6 +109,22 @@ OAUTH_TOKEN_URI="https://oauth-stable.dev.lcip.org/v1/token"
|
|||
|
||||
## Testing
|
||||
|
||||
The full test suite can be run via `npm test`.
|
||||
|
||||
### Individual tests
|
||||
|
||||
To run individual tests, use `NODE_ENV=tests` and `jest`:
|
||||
|
||||
```
|
||||
NODE_ENV=tests jest --runInBand tests/home.test.js
|
||||
```
|
||||
|
||||
To run tests with interactive `debugger` lines enabled:
|
||||
|
||||
```
|
||||
NODE_ENV=tests node inspect --harmony ./node_modules/.bin/jest tests/home.test.js
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
After installing the dependencies, you can lint the code by calling:
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
const express = require("express");
|
||||
|
||||
|
||||
function home(req, res) {
|
||||
let breach = null;
|
||||
|
@ -17,11 +15,11 @@ function home(req, res) {
|
|||
|
||||
|
||||
function notFound(req, res) {
|
||||
res.status(404)
|
||||
res.status(404);
|
||||
res.render("404");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
home,
|
||||
notFound,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
const httpMocks = require("node-mocks-http");
|
||||
|
||||
const home = require("../controllers/home");
|
||||
|
||||
|
||||
function addBreachesToMockRequest(mockRequest) {
|
||||
const mockBreaches = [
|
||||
{Name: 'Test'},
|
||||
{Name: 'DontShow'},
|
||||
{Name: "Test"},
|
||||
{Name: "DontShow"},
|
||||
];
|
||||
mockRequest.app = { locals: { breaches: mockBreaches } };
|
||||
return mockRequest;
|
||||
|
@ -28,7 +26,7 @@ test("home GET without breach renders monitor without breach", () => {
|
|||
|
||||
|
||||
test("home GET with breach renders monitor with breach", () => {
|
||||
const testBreach = {Name: 'Test'};
|
||||
const testBreach = {Name: "Test"};
|
||||
let mockRequest = { query: { breach: testBreach.Name } };
|
||||
mockRequest = addBreachesToMockRequest(mockRequest);
|
||||
const mockResponse = { render: jest.fn() };
|
||||
|
|
Загрузка…
Ссылка в новой задаче