forked from orbit-oss/is
parent
c68ad76062
commit
1f2440ae0d
3 changed files with 76 additions and 0 deletions
25
test/test.ts
25
test/test.ts
|
|
@ -2251,3 +2251,28 @@ test('custom assertion message', t => {
|
|||
assert.whitespaceString(undefined, message);
|
||||
}, {instanceOf: TypeError, message});
|
||||
});
|
||||
|
||||
test('is.optional', t => {
|
||||
t.true(is.optional(undefined, is.string));
|
||||
t.true(is.optional('🦄', is.string));
|
||||
t.false(is.optional(123, is.string));
|
||||
t.false(is.optional(null, is.string));
|
||||
});
|
||||
|
||||
test('assert.optional', t => {
|
||||
t.notThrows(() => {
|
||||
assert.optional(undefined, assert.string);
|
||||
});
|
||||
|
||||
t.notThrows(() => {
|
||||
assert.optional('🦄', assert.string);
|
||||
});
|
||||
|
||||
t.throws(() => {
|
||||
assert.optional(123, assert.string);
|
||||
});
|
||||
|
||||
t.throws(() => {
|
||||
assert.optional(null, assert.string);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue