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.
The provided plugins are:
unexpected-sinon
, for a better experience handling Sinon spies, mocks, etc.unexpected-immutable
, which provides handling of Immutable.js data structures.unexpected-reaction
, to allow test React components by their rendered DOM elements.unexpected-dom
provides a suite of assertions highly useful for testing the DOM output of components.
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
).
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.
Compares two array-like values' length.
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.
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.
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.
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.
Verifies that the subject fits the expected rules for a module object, gives useful error messages if it does not.
Checks that the subject is a valid column defintion as used by List components.
Checks that the array is a valid definition for a Form component, q.v.