|
4 | 4 | ReduxDevtoolsExtensionConnection,
|
5 | 5 | ReduxDevtoolsExtensionConfig,
|
6 | 6 | REDUX_DEVTOOLS_EXTENSION,
|
| 7 | + ExtensionActionTypes, |
7 | 8 | } from './../src/extension';
|
8 | 9 | import { Action } from '@ngrx/store';
|
9 | 10 |
|
@@ -182,6 +183,36 @@ describe('DevtoolsExtension', () => {
|
182 | 183 | );
|
183 | 184 | });
|
184 | 185 |
|
| 186 | + for (const { payload, name } of [ |
| 187 | + { |
| 188 | + payload: "{type: '[Books] Rent', id: 5, customerId: 12}", |
| 189 | + name: 'evaluates payload because of string', |
| 190 | + }, |
| 191 | + { |
| 192 | + payload: { type: '[Books] Rent', id: 5, customerId: 12 }, |
| 193 | + name: 'passes payload through if not of type string', |
| 194 | + }, |
| 195 | + ]) { |
| 196 | + it(`should handle an unlifted action (dispatched by DevTools) - ${name}`, () => { |
| 197 | + const { devtoolsExtension, extensionConnection } = testSetup({ |
| 198 | + config: createConfig({}), |
| 199 | + }); |
| 200 | + let unwrappedAction: Action | undefined = undefined; |
| 201 | + devtoolsExtension.actions$.subscribe((action) => { |
| 202 | + return (unwrappedAction = action); |
| 203 | + }); |
| 204 | + |
| 205 | + const [callback] = extensionConnection.subscribe.calls.mostRecent().args; |
| 206 | + callback({ type: ExtensionActionTypes.START }); |
| 207 | + callback({ type: ExtensionActionTypes.ACTION, payload }); |
| 208 | + expect(unwrappedAction).toEqual({ |
| 209 | + type: '[Books] Rent', |
| 210 | + id: 5, |
| 211 | + customerId: 12, |
| 212 | + }); |
| 213 | + }); |
| 214 | + } |
| 215 | + |
185 | 216 | describe('notify', () => {
|
186 | 217 | it('should send notification with default options', () => {
|
187 | 218 | const { devtoolsExtension, reduxDevtoolsExtension } = testSetup({
|
|
0 commit comments