File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
packages/hooks/src/useFormatResult/__tests__ Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ import useFormatResult from '..'
2
+
3
+ describe ( 'useFormatResult' , ( ) => {
4
+ it ( 'should inject data ' , ( ) => {
5
+ const name = useFormatResult ( { name : 'vue-hooks-plus' } , data => {
6
+ return data . name
7
+ } )
8
+
9
+ expect ( name . value ) . toBe ( 'vue-hooks-plus' )
10
+ } )
11
+ it ( 'should formatResult work' , ( ) => {
12
+ const name = useFormatResult ( { name : 'vue-hooks-plus' } , data => {
13
+ return `${ data . name } good`
14
+ } )
15
+ expect ( name . value ) . toBe ( 'vue-hooks-plus good' )
16
+ } )
17
+
18
+ it ( 'support undefined' , ( ) => {
19
+ const name = useFormatResult ( { name : 'vue-hooks-plus' } , ( ) => {
20
+ return undefined
21
+ } )
22
+ expect ( name . value ) . toBeUndefined ( )
23
+ } )
24
+
25
+ it ( 'support null' , ( ) => {
26
+ const name = useFormatResult ( { name : 'vue-hooks-plus' } , ( ) => {
27
+ return null
28
+ } )
29
+ expect ( name . value ) . toBeNull ( )
30
+ } )
31
+ } )
You can’t perform that action at this time.
0 commit comments