@@ -96,7 +96,7 @@ describe("getClientScope", () => {
9696 } ) ;
9797 /**
9898 * Current fix for this test is only implemented inside `[email protected] ` 99- *
99+ *
100100 * TODO: After fix is ported into original createWatch of `effector` package in the 23.0.0 release, remove skip
101101 */
102102 test . skip ( "watchers should re-run, if value is changed after server values injection" , async ( ) => {
@@ -159,6 +159,35 @@ describe("getClientScope", () => {
159159
160160 expect ( clientScopeTwo . getState ( $count ) ) . toEqual ( 4 ) ;
161161 } ) ;
162+
163+ test ( "should support custom serializers" , async ( ) => {
164+ const $homeDate = createStore < Date | null > ( null , {
165+ serialize : {
166+ read : ( dateStringOrNull ) =>
167+ typeof dateStringOrNull === "string"
168+ ? new Date ( dateStringOrNull )
169+ : null ,
170+ write : ( dateOrNull ) => ( dateOrNull ? dateOrNull . toISOString ( ) : null ) ,
171+ } ,
172+ sid : "test_sid" ,
173+ } ) ;
174+
175+ const serverScope = fork ( ) ;
176+
177+ await allSettled ( $homeDate , {
178+ scope : serverScope ,
179+ params : new Date ( 2024 , 10 , 3 ) ,
180+ } ) ;
181+
182+ const values = serialize ( serverScope ) ;
183+
184+ const scope = getScope ( values ) ;
185+
186+ const clientValue = scope . getState ( $homeDate ) ;
187+
188+ expect ( clientValue instanceof Date ) . toBe ( true ) ;
189+ expect ( clientValue ! . getTime ( ) ) . toEqual ( new Date ( 2024 , 10 , 3 ) . getTime ( ) ) ;
190+ } ) ;
162191} ) ;
163192
164193describe ( "getScope implementation details" , ( ) => {
0 commit comments