-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathpersonas.ts
31 lines (27 loc) · 1.1 KB
/
personas.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
export const personas: UserInfo[] = [
{ name: 'user 1', login: '[email protected]', password: 'user1' },
{ name: 'user 2', login: '[email protected]', password: 'user2' },
{ name: 'user 3', login: '[email protected]', password: 'user3' },
];
const userLogins: string[] = personas.map((p: UserInfo): string => p.login);
export function user(login: Email | undefined): UserInfo | undefined {
if (login === undefined) {
// eslint-disable-next-line no-console
console.warn(`User login is undefined. Available logins are: ${userLogins}.
(You can optionnaly add to the testcafe command-line the option: --user=${userLogins[0]})`);
return undefined;
}
const foundUser = personas.filter((p: UserInfo): boolean => p.login === login)[0];
if (foundUser) {
return foundUser;
}
// eslint-disable-next-line no-console
console.warn(`User login "${login}" is not found. Available logins are: ${userLogins}`);
return undefined;
}
export interface UserInfo {
name: string;
login: Email;
password?: string;
}