-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassertPathExists.test.ts
More file actions
27 lines (22 loc) · 824 Bytes
/
assertPathExists.test.ts
File metadata and controls
27 lines (22 loc) · 824 Bytes
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
import { describe, it, expect } from 'vitest';
import { assertPathExists } from '../../src/assertion/assertPathExists.js';
import { isNumber } from '../../src/predicate/isNumber.js';
import { isString } from '../../src/predicate/isString.js';
describe('assertPathExists()', () => {
it('Throws when path does not exist on object', () => {
expect(() => {
assertPathExists({ name: 'Test' }, 'name');
}).not.toThrowError();
expect(() => {
assertPathExists({ name: 'Test' }, 'age');
}).toThrowError();
});
it('Throws when path does not pass predicate validation', () => {
expect(() => {
assertPathExists({ name: 'Test' }, 'name', isString);
}).not.toThrowError();
expect(() => {
assertPathExists({ name: 'Test' }, 'name', isNumber);
}).toThrowError();
});
});