1- import { Worklets } from ' react-native-worklets' ;
2- import { Expect , ExpectException , ExpectValue } from ' ./utils' ;
1+ import { Worklets } from " react-native-worklets" ;
2+ import { Expect , ExpectException , ExpectValue } from " ./utils" ;
33
44export const sharedvalue_tests = {
55 get_set_numeric_value : ( ) => {
@@ -20,62 +20,62 @@ export const sharedvalue_tests = {
2020 } ,
2121
2222 get_set_string_value : ( ) => {
23- const sharedValue = Worklets . createSharedValue ( ' hello world' ) ;
24- sharedValue . value = ' hello worklet' ;
25- return ExpectValue ( sharedValue . value , ' hello worklet' ) ;
23+ const sharedValue = Worklets . createSharedValue ( " hello world" ) ;
24+ sharedValue . value = " hello worklet" ;
25+ return ExpectValue ( sharedValue . value , " hello worklet" ) ;
2626 } ,
2727
2828 get_set_object_value : ( ) => {
29- const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
29+ const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
3030 sharedValue . value . a = 50 ;
3131 sharedValue . value . b = 100 ;
32- return ExpectValue ( sharedValue . value , { a : 50 , b : 100 } ) ;
32+ return ExpectValue ( sharedValue . value , { a : 50 , b : 100 } ) ;
3333 } ,
3434
3535 get_set_array_value : ( ) => {
3636 const sharedValue = Worklets . createSharedValue ( [ 100 , 50 ] ) ;
3737 return ExpectValue ( sharedValue . value [ 0 ] , 100 ) . then ( ( ) =>
38- ExpectValue ( sharedValue . value [ 1 ] , 50 ) ,
38+ ExpectValue ( sharedValue . value [ 1 ] , 50 )
3939 ) ;
4040 } ,
4141
4242 box_number_to_string : ( ) => {
4343 const sharedValue = Worklets . createSharedValue ( 100 ) ;
4444 // @ts -ignore
45- sharedValue . value = ' 100' ;
46- return ExpectValue ( sharedValue . value , ' 100' ) ;
45+ sharedValue . value = " 100" ;
46+ return ExpectValue ( sharedValue . value , " 100" ) ;
4747 } ,
4848
4949 box_string_to_number : ( ) => {
50- const sharedValue = Worklets . createSharedValue ( ' 100' ) ;
50+ const sharedValue = Worklets . createSharedValue ( " 100" ) ;
5151 // @ts -ignore
5252 sharedValue . value = 100 ;
5353 return ExpectValue ( sharedValue . value , 100 ) ;
5454 } ,
5555
5656 box_string_to_array : ( ) => {
57- const sharedValue = Worklets . createSharedValue ( ' 100' ) ;
57+ const sharedValue = Worklets . createSharedValue ( " 100" ) ;
5858 // @ts -ignore
5959 sharedValue . value = [ 100 , 200 ] ;
6060 return ExpectValue ( sharedValue . value , [ 100 , 200 ] ) ;
6161 } ,
6262
6363 box_string_to_object : ( ) => {
64- const sharedValue = Worklets . createSharedValue ( ' 100' ) ;
64+ const sharedValue = Worklets . createSharedValue ( " 100" ) ;
6565 // @ts -ignore
66- sharedValue . value = { a : 100 , b : 200 } ;
67- return ExpectValue ( sharedValue . value , { a : 100 , b : 200 } ) ;
66+ sharedValue . value = { a : 100 , b : 200 } ;
67+ return ExpectValue ( sharedValue . value , { a : 100 , b : 200 } ) ;
6868 } ,
6969
7070 box_array_to_object : ( ) => {
7171 const sharedValue = Worklets . createSharedValue ( [ 100 , 200 ] ) ;
7272 // @ts -ignore
73- sharedValue . value = { a : 100 , b : 200 } ;
74- return ExpectValue ( sharedValue . value , { a : 100 , b : 200 } ) ;
73+ sharedValue . value = { a : 100 , b : 200 } ;
74+ return ExpectValue ( sharedValue . value , { a : 100 , b : 200 } ) ;
7575 } ,
7676
7777 box_object_to_array : ( ) => {
78- const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
78+ const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
7979 // @ts -ignore
8080 sharedValue . value = [ 100.34 , 200 ] ;
8181 return ExpectValue ( sharedValue . value , [ 100.34 , 200 ] ) ;
@@ -95,8 +95,8 @@ export const sharedvalue_tests = {
9595
9696 array_destructure_to_object : ( ) => {
9797 const sharedValue = Worklets . createSharedValue ( [ 100 , 200 ] ) ;
98- const p = { ...sharedValue . value } ;
99- return ExpectValue ( p , { 0 : 100 , 1 : 200 } ) ;
98+ const p = { ...sharedValue . value } ;
99+ return ExpectValue ( p , { 0 : 100 , 1 : 200 } ) ;
100100 } ,
101101
102102 array_length : ( ) => {
@@ -105,35 +105,35 @@ export const sharedvalue_tests = {
105105 } ,
106106
107107 object_value_destructure : ( ) => {
108- const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
109- const { a, b} = { ...sharedValue . value } ;
110- return ExpectValue ( { a, b} , { a : 100 , b : 100 } ) ;
108+ const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
109+ const { a, b } = { ...sharedValue . value } ;
110+ return ExpectValue ( { a, b } , { a : 100 , b : 100 } ) ;
111111 } ,
112112
113113 object_value_spread : ( ) => {
114- const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
115- const p = { ...sharedValue . value } ;
116- return ExpectValue ( p , { a : 100 , b : 200 } ) ;
114+ const sharedValue = Worklets . createSharedValue ( { a : 100 , b : 200 } ) ;
115+ const p = { ...sharedValue . value } ;
116+ return ExpectValue ( p , { a : 100 , b : 200 } ) ;
117117 } ,
118118
119119 set_value_from_worklet : ( ) => {
120- const sharedValue = Worklets . createSharedValue ( ' hello world' ) ;
120+ const sharedValue = Worklets . createSharedValue ( " hello world" ) ;
121121 const worklet = Worklets . createRunInContextFn ( function ( ) {
122- ' worklet' ;
123- sharedValue . value = ' hello worklet' ;
122+ " worklet" ;
123+ sharedValue . value = " hello worklet" ;
124124 } ) ;
125- sharedValue . value = ' hello worklet' ;
125+ sharedValue . value = " hello worklet" ;
126126 return Expect ( worklet ( ) , ( ) =>
127- sharedValue . value === ' hello worklet'
127+ sharedValue . value === " hello worklet"
128128 ? undefined
129- : `Expected ${ "'hello worklet'" } but got ${ sharedValue . value } ` ,
129+ : `Expected ${ "'hello worklet'" } but got ${ sharedValue . value } `
130130 ) ;
131131 } ,
132132
133133 set_function_with_error : ( ) => {
134134 return ExpectException ( ( ) => {
135135 Worklets . createSharedValue ( ( ) => { } ) ;
136- } , ' Regular javascript functions cannot be shared.' ) ;
136+ } , " Regular javascript functions cannot be shared." ) ;
137137 } ,
138138
139139 add_listener : ( ) => {
@@ -149,12 +149,12 @@ export const sharedvalue_tests = {
149149 add_listener_from_worklet_should_fail : ( ) => {
150150 const sharedValue = Worklets . createSharedValue ( 100 ) ;
151151 const worklet = Worklets . createRunInContextFn ( function ( ) {
152- ' worklet' ;
152+ " worklet" ;
153153 sharedValue . addListener ( ( ) => { } ) ;
154154 } ) ;
155155 return ExpectException (
156156 worklet ,
157- ' addListener can only be called from the main Javascript context and not from a worklet.' ,
157+ " addListener can only be called from the main Javascript context and not from a worklet."
158158 ) ;
159159 } ,
160160} ;
0 commit comments