From ba38a2c784ecae52757b48a1f2e23586c459592f Mon Sep 17 00:00:00 2001 From: Dmitry Ivakhnenko Date: Thu, 9 Feb 2023 02:15:43 -0800 Subject: [PATCH] Flex basis auto is mysteriously missed again (#1225) Summary: - adds a test to check that `setFlexBasisAuto` is here Pull Request resolved: https://github.com/facebook/yoga/pull/1225 Reviewed By: javache Differential Revision: D43150473 Pulled By: NickGerleman fbshipit-source-id: b5b82fe4a5db069d3ed5672990c9b8ade9141296 --- javascript/src_native/embind.cc | 1 + javascript/tests/YGFlexBasisAuto.test.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 javascript/tests/YGFlexBasisAuto.test.js diff --git a/javascript/src_native/embind.cc b/javascript/src_native/embind.cc index 91e6afc3..a59c8e40 100644 --- a/javascript/src_native/embind.cc +++ b/javascript/src_native/embind.cc @@ -89,6 +89,7 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) { .function("setFlex", &Node::setFlex) .function("setFlexBasis", &Node::setFlexBasis) .function("setFlexBasisPercent", &Node::setFlexBasisPercent) + .function("setFlexBasisAuto", &Node::setFlexBasisAuto) .function("setFlexGrow", &Node::setFlexGrow) .function("setFlexShrink", &Node::setFlexShrink) diff --git a/javascript/tests/YGFlexBasisAuto.test.js b/javascript/tests/YGFlexBasisAuto.test.js new file mode 100644 index 00000000..c68d3c6d --- /dev/null +++ b/javascript/tests/YGFlexBasisAuto.test.js @@ -0,0 +1,21 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +test("flex_basis_auto", () => { + const root = Yoga.Node.create(); + + expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_AUTO); + + root.setFlexBasis(10); + expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_POINT); + expect(root.getFlexBasis().value).toBe(10); + + root.setFlexBasisAuto(); + expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_AUTO); + + root.freeRecursive(); +});