diff --git a/packages/native/package.json b/packages/native/package.json index ab530c7..a9c36f1 100644 --- a/packages/native/package.json +++ b/packages/native/package.json @@ -34,6 +34,7 @@ "test": "NODE_ENV=test mocha" }, "dependencies": { + "dot-prop-immutable": "^2.1.1", "fast-deep-equal": "^3.1.3", "pretty-format": "^29.7.0", "tslib": "^2.6.2" diff --git a/packages/native/src/lib/ElementAssertion.ts b/packages/native/src/lib/ElementAssertion.ts index 3562c61..e9f206c 100644 --- a/packages/native/src/lib/ElementAssertion.ts +++ b/packages/native/src/lib/ElementAssertion.ts @@ -1,4 +1,5 @@ import { Assertion, AssertionError } from "@assertive-ts/core"; +import { get } from "dot-prop-immutable"; import prettyFormat, { plugins } from "pretty-format"; import { ReactTestInstance } from "react-test-renderer"; @@ -76,8 +77,8 @@ export class ElementAssertion extends Assertion { return ( !!element?.props?.disabled || - !!element?.props?.accessibilityState?.disabled || - !!element?.props?.accessibilityStates?.includes("disabled") + get(element, "props.accessibilityState.disabled", false) || + get(element, "props.accessibilityStates", []).includes("disabled") ); } diff --git a/yarn.lock b/yarn.lock index c06347d..59905c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -92,6 +92,7 @@ __metadata: "@types/react": "npm:^18.2.70" "@types/react-test-renderer": "npm:^18.0.7" "@types/sinon": "npm:^17.0.3" + dot-prop-immutable: "npm:^2.1.1" fast-deep-equal: "npm:^3.1.3" mocha: "npm:^10.3.0" pretty-format: "npm:^29.7.0"