(cmd, context)
| 167 | } |
| 168 | |
| 169 | function executeCmdInternal(cmd, context) { |
| 170 | switch (cmd.type) { |
| 171 | case cmdTypes.RUN: |
| 172 | return handleRunCmd(cmd, context); |
| 173 | |
| 174 | case cmdTypes.ACTION: |
| 175 | return Promise.resolve([cmd.actionToDispatch]); |
| 176 | |
| 177 | case cmdTypes.SET_TIMEOUT: |
| 178 | case cmdTypes.SET_INTERVAL: |
| 179 | return handleDelayCmd(cmd, context); |
| 180 | |
| 181 | case cmdTypes.LIST: |
| 182 | return cmd.sequence |
| 183 | ? handleSequenceList(cmd, context) |
| 184 | : handleParallelList(cmd, context); |
| 185 | |
| 186 | case cmdTypes.MAP: { |
| 187 | const possiblePromise = executeCmdInternal(cmd.nestedCmd, { |
| 188 | ...context, |
| 189 | wrappedDispatch: (action) => |
| 190 | context.wrappedDispatch(cmd.tagger(...cmd.args, action)), |
| 191 | }); |
| 192 | if (!possiblePromise) { |
| 193 | return null; |
| 194 | } |
| 195 | return possiblePromise.then((actions) => |
| 196 | actions.map((action) => cmd.tagger(...cmd.args, action)) |
| 197 | ); |
| 198 | } |
| 199 | |
| 200 | case cmdTypes.NONE: |
| 201 | return null; |
| 202 | |
| 203 | default: |
| 204 | throw new Error(`Invalid Cmd type ${cmd.type}`); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | function simulateRun({ result, success }) { |
| 209 | if (success && this.successActionCreator) { |
no test coverage detected