Add .nonEmptyStringAndNotWhitespace() (#161)

Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
This commit is contained in:
Ivan Katliarchuk 2022-02-25 09:10:57 +00:00 committed by GitHub
parent 04ccf21dba
commit 23cf074a73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

View file

@ -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