Skip to content

Latest commit

 

History

History
52 lines (28 loc) · 3.17 KB

assertions.md

File metadata and controls

52 lines (28 loc) · 3.17 KB

Available types and assertions for unexpected

This script toolbox contain a set of plugins and some custom types and assertions for unexpected, in order to make test writing easier and more intuitive.

Documentation for the built-in assertions can be found on the unexpected documentation site.

Plugins

The provided plugins are:

These plugins provide a wide array of tools to make for a pleasant testing experience, and demonstrations of common techniques can be found in the orc-shared test files (look for files like *.test.js).

Custom assertions

orc-scripts defines a number of custom assertions. The below documentation expects an at least cursory familiarity with unexpected itself and the above mentioned plugins.

<array-like> to be shorter than [or same length as] <array-like>

Compares two array-like values' length.

<string> as a selector to have style rules <assertion?>

Will go through the stylesheets of the DOM environment of the test, looking for styles fitting the selector string givenm, which are passed on to the later assertions.

<DOMElement> to have style rules satisfying <assertion>

This assertion will identify and search out styles matching any class name in the subject DOM element, in stylesheets rendered into the DOM. These will be passed on as a string to following assertions, enabling testing of the style output.

<function> to be a reducer with initial state <object>

This is a baseline test for reducer functions, ensuring that they behave as expected in standard cases. Specifically, it tests two things: That the reducer does not modify a state object passed to it along with an action of an unrelated type, and that in the case of initialization, it will return an initial state fitting the passed object pattern, turned into an Immutable data structure.

<any> to be a label

Checks that the subject is either a string, or an object with defaultMessage and id keys with string values, making it a legal react-intl message descriptor.

<object> to be a module structure

Verifies that the subject fits the expected rules for a module object, gives useful error messages if it does not.

<object> to be a column definition

Checks that the subject is a valid column defintion as used by List components.

<array-like> to be a form definition

Checks that the array is a valid definition for a Form component, q.v.