From f41d72f8664bb461ae805fd34410b58b3755e752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phu=CC=81c=20Hoa=CC=80?= <> Date: Fri, 29 Sep 2023 09:44:33 +0700 Subject: [PATCH] add get dot prop helper --- addon/helpers/get-dot-prop.js | 5 +++++ app/helpers/get-dot-prop.js | 1 + tests/integration/helpers/get-dot-prop-test.js | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 addon/helpers/get-dot-prop.js create mode 100644 app/helpers/get-dot-prop.js create mode 100644 tests/integration/helpers/get-dot-prop-test.js diff --git a/addon/helpers/get-dot-prop.js b/addon/helpers/get-dot-prop.js new file mode 100644 index 0000000..c79f2e2 --- /dev/null +++ b/addon/helpers/get-dot-prop.js @@ -0,0 +1,5 @@ +import { helper } from '@ember/component/helper'; + +export default helper(function getDotProp([object, key]) { + return object[key]; +}); diff --git a/app/helpers/get-dot-prop.js b/app/helpers/get-dot-prop.js new file mode 100644 index 0000000..6405287 --- /dev/null +++ b/app/helpers/get-dot-prop.js @@ -0,0 +1 @@ +export { default } from '@fleetbase/ember-ui/helpers/get-dot-prop'; diff --git a/tests/integration/helpers/get-dot-prop-test.js b/tests/integration/helpers/get-dot-prop-test.js new file mode 100644 index 0000000..98e4be8 --- /dev/null +++ b/tests/integration/helpers/get-dot-prop-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Helper | get-dot-prop', function (hooks) { + setupRenderingTest(hooks); + + // TODO: Replace this with your real tests. + test('it renders', async function (assert) { + this.set('inputValue', '1234'); + + await render(hbs`{{get-dot-prop this.inputValue}}`); + + assert.dom(this.element).hasText('1234'); + }); +});