-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathtoHaveStringLongerThan.spec.js
45 lines (44 loc) · 1.56 KB
/
toHaveStringLongerThan.spec.js
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
const describeToHaveX = require('./lib/describeToHaveX');
describe('toHaveStringLongerThan', () => {
describeToHaveX('toHaveStringLongerThan', () => {
describe('when the subject and comparison ARE both strings', () => {
describe('when the subject IS longer than the comparision string', () => {
it('should confirm', () => {
expect({
memberName: 'abc'
}).toHaveStringLongerThan('memberName', 'ab');
expect({
memberName: 'a'
}).toHaveStringLongerThan('memberName', '');
});
});
describe('when the subject is NOT longer than the comparision string', () => {
it('should deny', () => {
expect({
memberName: 'ab'
}).not.toHaveStringLongerThan('memberName', 'abc');
expect({
memberName: ''
}).not.toHaveStringLongerThan('memberName', 'a');
});
});
});
describe('when the subject and comparison are NOT both strings', () => {
it('should deny (we are asserting the relative lengths of two strings)', () => {
let _undefined;
expect({
memberName: 'truthy'
}).not.toHaveStringLongerThan('memberName', _undefined);
expect({
memberName: _undefined
}).not.toHaveStringLongerThan('memberName', 'truthy');
expect({
memberName: ''
}).not.toHaveStringLongerThan('memberName', _undefined);
expect({
memberName: _undefined
}).not.toHaveStringLongerThan('memberName', '');
});
});
});
});