Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add tests to compare arrays and proxy arrays #161

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions example/Tests/wrapper-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,29 @@ export const wrapper_tests = {
return ExpectValue(sum, 300);
},

array_proxy_has_same_methods_as_normal_array: () => {
const array = [100, 200];
const proxy = Worklets.createSharedValue([100, 200]);

const arrayKeys = Object.keys(array);
const proxyKeys = Object.keys(proxy);
return ExpectValue(arrayKeys, proxyKeys);
},

array_proxy_all_methods_are_same_type_as_normal_array: () => {
// compares if all properties in a normal array have the same type (e.g. function)
// as in our proxy arrays.
const array = [100, 200];
const proxy = Worklets.createSharedValue([100, 200]);

const arrayKeys = Object.keys(array);
return ExpectValue(
// @ts-expect-error these properties are accessed differently
arrayKeys.every((k) => typeof array[k] === proxy.value[k]),
true
);
},

convert_array_FAILS: convert([123, "abc"]),
convert_array_of_objects_FAILS: convert([
{ x: 1, y: 2 },
Expand Down
Loading