Type Enforcer Test Helper
Test data and helper functions for type-enforcer and addons
Installation
npm install type-enforcer-test-helper
About
This library consists of two things. First is a data set of variations of different data type instances and values, along with coercible values, many of which were hand picked from the big-list-of-naughty-strings. Second is a handful of functions to help in testing type-enforcer and type-enforcer addons.
Classes
- TestClass
A simple class for testing things like instanceof
Constants
- testTypes :
Array
An array of all the test type objects (arrayData, booleanData, etc.)
- arrayData :
object
A data set for testing Arrays
- booleanData :
object
A data set for testing Booleans
- dateData :
object
A data set for testing Dates
- functionData :
object
A data set for testing Functions
- instanceData :
object
A data set for testing instanceOf
- integerData :
object
A data set for testing integers
- jsonData :
object
A data set for testing JSON
- floatData :
object
A data set for testing integers
- numberData :
object
A data set for testing numbers
- mapData :
object
A data set for testing Maps
- objectData :
object
A data set for testing plain Objects
- promiseData :
object
A data set for testing Promises
- regExpData :
object
A data set for testing RegExps
- setData :
object
A data set for testing Sets
- stringData :
object
A data set for testing Strings
- symbolData :
object
A data set for testing Symbols
- weakMapData :
object
A data set for testing WeakMaps
- weakSetData :
object
A data set for testing WeakSets
- testValues :
Array
A concatenated array of all the "valid" arrays.
- validArrays :
Array
Arrays instantiated in different ways or with different values.
- validBooleans :
Array
Booleans instantiated in different ways or with different values.
- validDates :
Array
Dates instantiated in different ways or with different values.
- validFunctions :
Array
Functions instantiated in different ways.
- validInstances :
Array
Different instances of TestClass with different values.
- validIntegers :
Array
Integers instantiated in different ways or with different values.
- validFloats :
Array
Floats instantiated in different ways or with different values.
- validInfinities :
Array
Infinity and -Infinity
- validMaps :
Array
An empty Map and a Map with data.
- validObjects :
Array
Plain objects instantiated in different ways or with different values.
- validPromises :
Array
A normal Promise and Promise.all.
- validRegExps :
Array
RegExps instantiated in different ways or with different values.
- validSets :
Array
An empty Set and a Set with data.
- validStrings :
Array
Strings instantiated in different ways or with different values.
- validSymbols :
Array
A Symbol with a label and one without.
- validWeakMaps :
Array
An empty WeakMap and a WeakMap with data.
- validWeakSets :
Array
An empty WeakSet and a WeakSet with data.
- validNots :
Array
Undefined, null, and NaN
Functions
- multiTest(settings)
Run multiple identical tests over a set of data.
- testCheck(data, check, is)
Test a type-enforcer check function (isArray, isBoolean, etc.).
- testEnforce(data, enforcer, enforce, coercer)
Test an enforce function (enforceArray, enforceBoolean, etc.).
- testMethod(settings, thisMethod, method)
Test a chainable method function (methodArray, methodBoolean, etc.).