jest-redux-thunk
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -6,7 +6,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var toBeDispatchedWithAction_1 = __importDefault(require("./toBeDispatchedWithAction")); | ||
var toBeDispatchedWithActionType_1 = __importDefault(require("./toBeDispatchedWithActionType")); | ||
var toBeDispatchedWithActionTypeOrder_1 = __importDefault(require("./toBeDispatchedWithActionTypeOrder")); | ||
expect.extend({ | ||
toBeDispatchedWithAction: toBeDispatchedWithAction_1.default, | ||
toBeDispatchedWithActionType: toBeDispatchedWithActionType_1.default, | ||
toBeDispatchedWithActionTypeOrder: toBeDispatchedWithActionTypeOrder_1.default | ||
}); |
@@ -8,3 +8,2 @@ "use strict"; | ||
utils_1.assertActionTypeProvided(expectedActionType); | ||
// assert this is a mock | ||
var calls = receivedDispatchMock.mock.calls; | ||
@@ -11,0 +10,0 @@ // check to see if dispatchMock was called at all |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var jest_utils_1 = require("./jest-utils"); | ||
exports.toMatchObjectComparison = jest_utils_1.toMatchObjectComparison; | ||
exports.assertIsMockFunction = function (mock) { | ||
@@ -4,0 +6,0 @@ if (mock._isMockFunction !== true) { |
@@ -15,3 +15,11 @@ declare namespace jest { | ||
) => R; | ||
/** | ||
* Expects that passed in mock function has been called with an action that matches | ||
* expected action using subset matching (similar to "toMatchObject" functionality) | ||
*/ | ||
toBeDispatchedWithAction: ( | ||
action: { type: string; [prop: string]: any } | ||
) => R; | ||
} | ||
} |
{ | ||
"name": "jest-redux-thunk", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/mcMickJuice/jest-redux-thunk", |
@@ -63,2 +63,38 @@ # jest-redux-thunk | ||
### `toBeDispatchedWithAction` | ||
Asserts that an action and its data match what is dispatched. This is similar to `toMatchObject` where the subset comparison is performed on each key of the action (e.g. `payload`, `meta`, etc) | ||
```javascript | ||
import `jest-redux-thunk` | ||
it('dispatches LOAD_STORY action', () => { | ||
const dispatchMock = jest.fn() | ||
dispatchMock ({ | ||
type: 'LOAD_STORY', | ||
payload: { | ||
items: ['book1', 'book2', 'book3'] | ||
}, | ||
meta: { | ||
isLoading: false | ||
} | ||
}) | ||
expect(dispatchMock).toBeDispatchedWithAction({ | ||
type: 'LOAD_STORY', | ||
// this payload object is a subset of the payload object above | ||
payload: { | ||
items: ['book1', 'book2', 'book3'] | ||
} | ||
}) | ||
}) | ||
``` | ||
This matcher will fail if: | ||
- no action is dispatched | ||
- multiple actions with the same expected action.type are dispatched | ||
- the action dispatched does not match the expected action (using similar logic to `toMatchObject`) | ||
# FAQ (actually, just one question that some might have regarding these matchers) | ||
@@ -65,0 +101,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32012
12
660
150
1