JamieMason/expect-more

View on GitHub
packages/expect-more/src/is-whitespace.ts

Summary

Maintainability
A
0 mins
Test Coverage
D
66%
import { isString } from './is-string';

/**
 * Asserts that a value is a `String` containing only whitespace characters.
 * @param value ' '
 * @matcherName toBeWhitespace
 * @memberMatcherName toHaveWhitespace
 * @matcherMessage expected ${value} to be a string containing only whitespace
 * characters
 * @matcherNotMessage expected ${value} not to be a string containing only
 * whitespace characters
 */
export const isWhitespace = (value: unknown): value is string =>
  isString(value) && value.search(/\S/) === -1;