-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth-web-view.web.test.tsx
More file actions
40 lines (34 loc) · 1.24 KB
/
Copy pathauth-web-view.web.test.tsx
File metadata and controls
40 lines (34 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import AuthWebView from "@/components/authentication/AuthWebView.web";
import { fireEvent, render, waitFor } from "@testing-library/react-native";
import React from "react";
describe("AuthWebView web", () => {
it("accepts a pasted token", async () => {
const onLogin = jest.fn();
const authView = render(<AuthWebView onLogin={onLogin} />);
fireEvent.changeText(authView.getByTestId("calendar-web-auth-input"), "token-123");
fireEvent.press(authView.getByTestId("calendar-web-auth-submit"));
await waitFor(() => {
expect(onLogin).toHaveBeenCalledWith({
authToken: "token-123",
firstName: "Concordia",
lastNameInitial: "",
});
});
});
it("extracts the token from a pasted cookie string", async () => {
const onLogin = jest.fn();
const authView = render(<AuthWebView onLogin={onLogin} />);
fireEvent.changeText(
authView.getByTestId("calendar-web-auth-input"),
"Given-Name=Ben; Surname=L; SSO-Token=token==",
);
fireEvent.press(authView.getByTestId("calendar-web-auth-submit"));
await waitFor(() => {
expect(onLogin).toHaveBeenCalledWith({
authToken: "token==",
firstName: "Ben",
lastNameInitial: "L",
});
});
});
});