-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmatch.test.ts
More file actions
53 lines (49 loc) · 1.66 KB
/
match.test.ts
File metadata and controls
53 lines (49 loc) · 1.66 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
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) 2025 Ping Identity Corporation. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import { it } from '@effect/vitest';
import { expect } from 'vitest';
import { PingRequestData, validator } from '../match.js';
import { Effect, Exit } from 'effect';
import { InvalidUsernamePassword, InvalidProtectNode } from '../../errors/index.js';
it.effect('match validation function passes username password validation', () =>
Effect.gen(function* () {
const body: PingRequestData = {
username: 'testuser',
password: 'Password',
};
const result = yield* validator(body);
expect(result).toEqual(true);
}),
);
it.effect('match validation function fails username password validation', () =>
Effect.gen(function* () {
const body: PingRequestData = {
username: 'testuser',
password: 'bad-password',
};
const result = yield* validator(body).pipe(Effect.exit);
expect(result).toEqual(Exit.fail(new InvalidUsernamePassword()));
}),
);
it.effect('match validation function passes ping protect node validaiton', () =>
Effect.gen(function* () {
const body: PingRequestData = {
pingprotectsdk: '12321321980123',
};
const result = yield* validator(body);
expect(result).toEqual(true);
}),
);
it.effect('match validation function fails ping protect node validaiton', () =>
Effect.gen(function* () {
const body: PingRequestData = {
pingprotectsdk: '',
};
const result = yield* validator(body).pipe(Effect.exit);
expect(result).toStrictEqual(Exit.fail(new InvalidProtectNode()));
}),
);