JamieMason/expect-more

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

Summary

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

/**
 * Asserts that a value is a valid `String` containing at least one character
 * which is not whitespace.
 * @param value 'i am visible'
 * @matcherName toBeVisibleString
 * @memberMatcherName toHaveVisibleString
 * @matcherMessage expected ${value} to be a string with at least one
 * non-whitespace character
 * @matcherNotMessage expected ${value} not to be a string with at least one
 * non-whitespace character
 */
export const isVisibleString = (value: unknown): value is string =>
  isString(value) && value.length > 0 && value.search(/\S/) !== -1;