-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ new API - new helpers - tests (#8)
- Loading branch information
1 parent
dc10376
commit 0b2d70e
Showing
23 changed files
with
1,792 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`getAction maper should map a simple mobx-state-tree action 1`] = ` | ||
Object { | ||
"args": Array [ | ||
"first", | ||
Object { | ||
"second": "argument", | ||
}, | ||
], | ||
"fullpath": "/this/is/a/path/actionName", | ||
"name": "actionName", | ||
"path": "/this/is/a/path", | ||
} | ||
`; | ||
|
||
exports[`getAction maper should map an asynchronous action that ends 1`] = ` | ||
Object { | ||
"args": Array [ | ||
"first", | ||
Object { | ||
"second": "argument", | ||
}, | ||
], | ||
"ended": true, | ||
"fullpath": "/this/is/a/path/actionName", | ||
"name": "actionName", | ||
"path": "/this/is/a/path", | ||
} | ||
`; | ||
|
||
exports[`getAction maper should map an undefined type 1`] = `undefined`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`middleware should call runArray 1`] = `"i am next"`; | ||
|
||
exports[`middleware should call runArray 2`] = ` | ||
Array [ | ||
Array [ | ||
Array [], | ||
Object { | ||
"call": Object { | ||
"tree": Object { | ||
"this": "is tree", | ||
}, | ||
"type": "action", | ||
}, | ||
"mocked": "getAction", | ||
}, | ||
Object { | ||
"this": "is tree", | ||
}, | ||
], | ||
] | ||
`; | ||
|
||
exports[`middleware should call runArray 3`] = `Array []`; | ||
|
||
exports[`middleware should call runFunction 1`] = `"i am next"`; | ||
|
||
exports[`middleware should call runFunction 2`] = `Array []`; | ||
|
||
exports[`middleware should call runFunction 3`] = ` | ||
Array [ | ||
Array [ | ||
[Function], | ||
Object { | ||
"call": Object { | ||
"tree": Object { | ||
"this": "is tree", | ||
}, | ||
"type": "action", | ||
}, | ||
"mocked": "getAction", | ||
}, | ||
Object { | ||
"this": "is tree", | ||
}, | ||
], | ||
] | ||
`; | ||
|
||
exports[`middleware should not call runner (no action) 1`] = `"i am next"`; | ||
|
||
exports[`middleware should not call runner (no action) 2`] = `Array []`; | ||
|
||
exports[`middleware should not call runner (no action) 3`] = `Array []`; | ||
|
||
exports[`middleware should throw an error (unknown dispatch type) 1`] = `[Error: [trampss-mst-onaction] unknow dispatch type]`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { getPath } from 'mobx-state-tree' | ||
|
||
export default (call) => { | ||
const { | ||
name, | ||
type, | ||
context, | ||
args, | ||
} = call | ||
|
||
const path = getPath(context) | ||
const fullpath = `${path}/${name}` | ||
|
||
const action = { | ||
fullpath, | ||
path, | ||
name, | ||
args, | ||
} | ||
|
||
switch (type) { | ||
case 'process_return': return { ...action, ended: true } | ||
case 'action': return action | ||
default: return undefined | ||
} | ||
} |
Oops, something went wrong.