@@ -8,11 +8,14 @@ jest.mock('svelte')
8
8
function setupStore ( ) {
9
9
function counter ( store ) {
10
10
store . on ( '@init' , ( ) => {
11
- return { count : 0 , foo : 'baz' }
11
+ return { count : 0 , foo : 'baz' , loading : false }
12
12
} )
13
13
store . on ( 'inc' , state => {
14
14
return { count : state . count + 1 }
15
15
} )
16
+ store . on ( 'toggle' , state => {
17
+ return { loading : ! state . loading }
18
+ } )
16
19
}
17
20
18
21
return createStoreon ( [ counter ] )
@@ -93,7 +96,7 @@ it('should not emit changes on other dispatches', () => {
93
96
expect ( countSpyCb ) . toHaveBeenCalledTimes ( 1 )
94
97
} )
95
98
96
- it ( 'shoud to be unsubscribed' , ( ) => {
99
+ it ( 'should to be unsubscribed' , ( ) => {
97
100
let currentValue
98
101
let { count, dispatch } = useStoreon ( 'count' )
99
102
@@ -111,3 +114,26 @@ it('shoud to be unsubscribed', () => {
111
114
112
115
expect ( currentValue ) . toBe ( 1 )
113
116
} )
117
+
118
+ it ( 'should work with boolean values' , ( ) => {
119
+ let currentValue
120
+ let { loading, dispatch } = useStoreon ( 'loading' )
121
+
122
+ let unsubscribe = loading . subscribe ( value => { currentValue = value } )
123
+
124
+ expect ( currentValue ) . toBe ( false )
125
+
126
+ dispatch ( 'toggle' )
127
+
128
+ expect ( currentValue ) . toBe ( true )
129
+
130
+ dispatch ( 'toggle' )
131
+
132
+ expect ( currentValue ) . toBe ( false )
133
+
134
+ unsubscribe ( )
135
+
136
+ dispatch ( 'toggle' )
137
+
138
+ expect ( currentValue ) . toBe ( false )
139
+ } )
0 commit comments