Skip to content

Commit 3494b92

Browse files
committed
Testing behaviour of object spreading
1 parent d0900ea commit 3494b92

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

example/Tests/worklet-context-tests.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,67 @@ export const worklet_context_tests = {
379379
});
380380
return ExpectValue(result, 1200);
381381
},
382+
test1: async () => {
383+
const fw = () => {
384+
"worklet";
385+
return [{ a: 100 }];
386+
};
387+
let wf = Worklets.defaultContext.createRunAsync(fw);
388+
const result = await wf();
389+
const firstResult = result[0];
390+
const firstResultSpread = { ...firstResult };
391+
return ExpectValue(firstResultSpread, { a: 100 });
392+
},
393+
test2: async () => {
394+
const fw = () => {
395+
"worklet";
396+
return [{ a: 100 }];
397+
};
398+
let wf = Worklets.defaultContext.createRunAsync(fw);
399+
const result = await wf();
400+
const firstResult = result[0];
401+
const firstResultSpread = Object.assign({}, firstResult);
402+
return ExpectValue(firstResultSpread, { a: 100 });
403+
},
404+
test3: async () => {
405+
const fw = () => {
406+
"worklet";
407+
return [{ a: 100 }];
408+
};
409+
let wf = Worklets.defaultContext.createRunAsync(fw);
410+
const result = await wf();
411+
const firstResult = result[0];
412+
const testingObject = { a: firstResult.a };
413+
return ExpectValue(testingObject, { a: 100 });
414+
},
415+
test1a: async () => {
416+
const fw = () => {
417+
"worklet";
418+
return { a: 100 };
419+
};
420+
let wf = Worklets.defaultContext.createRunAsync(fw);
421+
const result = await wf();
422+
const firstResultSpread = { ...result };
423+
return ExpectValue(firstResultSpread, { a: 100 });
424+
},
425+
test2a: async () => {
426+
const fw = () => {
427+
"worklet";
428+
return { a: 100 };
429+
};
430+
let wf = Worklets.defaultContext.createRunAsync(fw);
431+
const result = await wf();
432+
const firstResultSpread = Object.assign({}, result);
433+
return ExpectValue(firstResultSpread, { a: 100 });
434+
},
435+
test3a: async () => {
436+
const fw = () => {
437+
"worklet";
438+
return { a: 100 };
439+
};
440+
let wf = Worklets.defaultContext.createRunAsync(fw);
441+
const result = await wf();
442+
const testingObject = { a: result.a };
443+
return ExpectValue(testingObject, { a: 100 });
444+
},
382445
};

0 commit comments

Comments
 (0)