Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-redux-thunk

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-redux-thunk - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

dist/jest-utils/index.js

2

dist/index.js

@@ -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
});

1

dist/toBeDispatchedWithActionType.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc