Test helpers
This module hosts everything needed for tests. Abstraction over the expection engine, abstraction over the basic functions, this module is the Test Toolbelt. Little to no test framework logic should be in unit tests to keep them focused on code documentation.
- Source:
Members
(inner) prepareForTests
Prepare a module for tests by requiring it with stubs and eventually creating an instance from its factory if it has any. Module name is based on the given fileName which is the test file name that will consume the prepared module.
- Source:
Methods
(static) createResponseMock() → {Object}
Create an Express-like response mock
- Source:
Returns:
Response mock
- Type
- Object
(static) idFn(input) → {Mixed}
Identity function
Parameters:
| Name | Type | Description |
|---|---|---|
input |
Mixed | Value to be returned |
- Source:
Returns:
Same as input
- Type
- Mixed
(static) nullFn() → {Null}
Returns null
- Source:
Returns:
Null
- Type
- Null
(static) nullFnHO() → {function}
Returns a function that returns null
- Source:
Returns:
Function that returns null
- Type
- function
(static) rejectFn(reason) → {Promise.<Mixed>}
Returns a rejected Promise
Parameters:
| Name | Type | Description |
|---|---|---|
reason |
String | Rejection reason |
- Source:
Returns:
Promise rejected with given reason
- Type
- Promise.<Mixed>
(static) resolveFn(value) → {Promise.<Mixed>}
Returns a resolved Promise
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | Resolved value |
- Source:
Returns:
Promise resoved with given value
- Type
- Promise.<Mixed>
(static) resolveFnHO(value) → {function}
Returns a function that return a resolved Promise with given value
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | Resolved value |
- Source:
Returns:
Function that returns a resolved Promise with given value
- Type
- function
(static) t(parentBlockDescription, blockDescriptionopt, cb) → {function}
Returns a function that will execute several tests with a concatenated description
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
parentBlockDescription |
String | Parent block description |
|
blockDescription |
String |
<optional> |
This test block description |
cb |
function | Callback |
- Source:
Returns:
Test block handler
- Type
- function
(static) throwFn(error) → {Error}
Throws an Error
Parameters:
| Name | Type | Description |
|---|---|---|
error |
String | Error message |
- Source:
Returns:
Error thrown
- Type
- Error
(static) throwFnHO(error) → {function}
Returns a function that throws an Error
Parameters:
| Name | Type | Description |
|---|---|---|
error |
String | Error message |
- Source:
Returns:
Function that throws an error
- Type
- function