forked from cypress-io/cypress-realworld-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
users.test.ts
53 lines (38 loc) · 1.49 KB
/
users.test.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
import { describe, expect, it, beforeEach } from "vitest";
import { seedDatabase, getAllUsers, searchUsers } from "../../backend/database";
import { User } from "../models";
describe("Users", () => {
beforeEach(() => {
seedDatabase();
});
it("should get a user by email address", () => {
const userToLookup: User = getAllUsers()[0];
const { email } = userToLookup;
const users = searchUsers(email);
expect(users.length).toBeGreaterThanOrEqual(1);
expect(users[0].id).toBe(userToLookup.id);
});
it("should get a user by username", () => {
const userToLookup: User = getAllUsers()[0];
const { username } = userToLookup;
const users = searchUsers(username);
expect(users.length).toBeGreaterThanOrEqual(1);
expect(users[0].id).toBe(userToLookup.id);
});
it("should get a user by phone number", () => {
const userToLookup: User = getAllUsers()[0];
const { phoneNumber } = userToLookup;
const users = searchUsers(phoneNumber);
expect(users.length).toBeGreaterThanOrEqual(1);
expect(users[0].id).toBe(userToLookup.id);
});
it("should get a list of users by alpha (username, email) (fuzzy match)", () => {
const userToLookup: User = getAllUsers()[0];
const users = searchUsers(userToLookup.firstName);
expect(users.length).toBeGreaterThanOrEqual(1);
});
it("should get a list of users by phone (fuzzy match)", () => {
const users = searchUsers("201");
expect(users.length).toBeGreaterThanOrEqual(1);
});
});