Update related tests.
This commit is contained in:
Родитель
be0be8fd5e
Коммит
df5871cda1
|
@ -1,7 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
const AppConstants = require("../../app-constants");
|
||||
const home = require("../../controllers/home");
|
||||
|
||||
const scanResult = require("../../scan-results");
|
||||
|
||||
let mockRequest = { fluentFormat: jest.fn() };
|
||||
|
||||
|
@ -28,17 +29,21 @@ test("home GET without breach renders monitor without breach", () => {
|
|||
});
|
||||
|
||||
|
||||
test("home GET with breach renders monitor with breach", () => {
|
||||
test("home GET with breach renders monitor with breach", async() => {
|
||||
const testBreach = {Name: "Test"};
|
||||
mockRequest.query = { breach: testBreach.Name };
|
||||
mockRequest = addBreachesToMockRequest(mockRequest);
|
||||
mockRequest.url = "https://www.mozilla.com";
|
||||
mockRequest.session = { user: null };
|
||||
const mockResponse = { render: jest.fn() };
|
||||
mockRequest.url = { url: "https://www.mozilla.com" };
|
||||
mockRequest.app.locals.SERVER_URL = AppConstants.SERVER_URL;
|
||||
|
||||
|
||||
const mockResponse = { render: jest.fn(), redirect: jest.fn() };
|
||||
home.home(mockRequest, mockResponse);
|
||||
const scanRes = await scanResult(mockRequest);
|
||||
|
||||
expect(scanRes.doorhangerScan).toBe(false);
|
||||
expect(scanRes.selfScan).toBe(false);
|
||||
const mockRenderCallArgs = mockResponse.render.mock.calls[0];
|
||||
expect(mockRenderCallArgs[0]).toBe("monitor");
|
||||
expect(mockRenderCallArgs[1].featuredBreach).toEqual(testBreach);
|
||||
|
|
|
@ -67,7 +67,7 @@ test("confirmed request checks session cookie, calls FXA for token and email, ad
|
|||
expect(subscribers[0].signup_language).toBe(userAddLanguages);
|
||||
|
||||
const mockRedirectCallArgs = mockResponse.redirect.mock.calls[0];
|
||||
expect(mockRedirectCallArgs[0]).toBe("/scan/latest_breaches");
|
||||
expect(mockRedirectCallArgs[0]).toBe("/scan/user_dashboard");
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
const AppConstants = require("../../app-constants");
|
||||
const sha1 = require("../../sha1-utils");
|
||||
const HIBP = require("../../hibp");
|
||||
const scan = require("../../controllers/scan");
|
||||
|
@ -39,6 +39,8 @@ test("scan POST with hash should render scan with foundBreaches", async () => {
|
|||
mockRequest.body = { emailHash: sha1(testEmail) };
|
||||
mockRequest.app = { locals: { breaches: testBreaches } };
|
||||
mockRequest.session = { user: null };
|
||||
mockRequest.url = { url: "https://www.mozilla.com" };
|
||||
mockRequest.app.locals.SERVER_URL = AppConstants.SERVER_URL;
|
||||
const mockResponse = { render: jest.fn() };
|
||||
HIBP.getBreachesForEmail.mockResolvedValue(testFoundBreaches);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче