-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnot.test.ts
37 lines (29 loc) · 1.13 KB
/
not.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
import { describe, it } from 'node:test';
import expect from 'expect';
import { dom } from '../helpers';
import { createInteractor, not, including } from '../../src/index';
const HTML = createInteractor<HTMLElement>('html')
.filters({
id: (e) => e.id,
title: (e) => e.title,
});
const div = HTML({ id: "test-div" });
describe('not', () => {
it('can check whether the filter does not match the given matcher', async () => {
dom(`
<div id="test-div" title="hello cruel world"></div>
`);
await div.has({ title: not(including("monkey")) });
await expect(div.has({ title: not(including('world')) })).rejects.toHaveProperty('name', 'FilterNotMatchingError');
});
it('can check whether the filter does not match the given literal value', async () => {
dom(`
<div id="test-div" title="hello"></div>
`);
await div.has({ title: not('monkey') });
await expect(div.has({ title: not('hello') })).rejects.toHaveProperty('name', 'FilterNotMatchingError');
});
it('can return code representation', () => {
expect(not(including('monkey')).code?.()).toBe('not(including("monkey"))')
})
});