Add .nonEmptyStringAndNotWhitespace() (#161)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
This commit is contained in:
parent
04ccf21dba
commit
23cf074a73
3 changed files with 38 additions and 0 deletions
21
test/test.ts
21
test/test.ts
|
|
@ -1436,6 +1436,27 @@ test('is.emptyStringOrWhitespace', t => {
|
|||
});
|
||||
});
|
||||
|
||||
test('is.nonEmptyStringAndNotWhitespace', t => {
|
||||
t.false(is.nonEmptyStringAndNotWhitespace(' '));
|
||||
t.true(is.nonEmptyStringAndNotWhitespace('🦄'));
|
||||
|
||||
for (const value of [null, undefined, 5, NaN, {}, []]) {
|
||||
t.false(is.nonEmptyStringAndNotWhitespace(value));
|
||||
|
||||
t.throws(() => {
|
||||
assert.nonEmptyStringAndNotWhitespace(value);
|
||||
});
|
||||
}
|
||||
|
||||
t.throws(() => {
|
||||
assert.nonEmptyStringAndNotWhitespace('');
|
||||
});
|
||||
|
||||
t.notThrows(() => {
|
||||
assert.nonEmptyStringAndNotWhitespace('🦄');
|
||||
});
|
||||
});
|
||||
|
||||
test('is.emptyObject', t => {
|
||||
t.true(is.emptyObject({}));
|
||||
t.true(is.emptyObject(new Object())); // eslint-disable-line no-new-object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue