diff --git a/packages/@ember/-internals/glimmer/index.ts b/packages/@ember/-internals/glimmer/index.ts index 825c26f6dbf..b64a7944168 100644 --- a/packages/@ember/-internals/glimmer/index.ts +++ b/packages/@ember/-internals/glimmer/index.ts @@ -324,3 +324,4 @@ export { setComponentManager, } from './lib/utils/managers'; export { isSerializationFirstNode } from './lib/utils/serialization-first-node-helpers'; +export { default as uniqueId } from './lib/helpers/unique-id'; diff --git a/packages/@ember/-internals/glimmer/tests/integration/helpers/unique-id-test.js b/packages/@ember/-internals/glimmer/tests/integration/helpers/unique-id-test.js index 65fe72f9347..e1261948040 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/helpers/unique-id-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/helpers/unique-id-test.js @@ -1,8 +1,35 @@ -import { RenderingTestCase, strip, moduleFor, runTask } from 'internal-test-helpers'; +import { + AbstractTestCase, + RenderingTestCase, + strip, + moduleFor, + runTask, +} from 'internal-test-helpers'; import { setProperties } from '@ember/object'; +import { uniqueId, invokeHelper } from '@ember/helper'; import { EMBER_UNIQUE_ID_HELPER } from '@ember/canary-features'; +import { getValue } from '@glimmer/validator'; if (EMBER_UNIQUE_ID_HELPER) { + moduleFor( + 'Helpers test: {{unique-id}} JS', + class JSRenderingTest extends AbstractTestCase { + constructor(assert) { + super(assert); + this.assert = assert; + } + ['@test it can be invoked as a JS function']() { + let first = getValue(invokeHelper({}, uniqueId())); + let second = getValue(invokeHelper({}, uniqueId())); + + this.assert.notStrictEqual( + first, + second, + `different invocations of uniqueId should produce different values` + ); + } + } + ); moduleFor( 'Helpers test: {{unique-id}}', class extends RenderingTestCase { diff --git a/packages/@ember/helper/index.ts b/packages/@ember/helper/index.ts index 47f98763171..9b81b823bc7 100644 --- a/packages/@ember/helper/index.ts +++ b/packages/@ember/helper/index.ts @@ -314,3 +314,5 @@ export { setHelperManager, helperCapabilities as capabilities } from '@glimmer/manager'; export { invokeHelper, hash, array, concat, get, fn } from '@glimmer/runtime'; + +export { uniqueId } from '@ember/-internals/glimmer'; diff --git a/packages/ember/tests/reexports_test.js b/packages/ember/tests/reexports_test.js index e60b94bca7e..376370e8604 100644 --- a/packages/ember/tests/reexports_test.js +++ b/packages/ember/tests/reexports_test.js @@ -169,6 +169,7 @@ let allExports = [ ['_hash', '@ember/helper', 'hash'], ['_get', '@ember/helper', 'get'], ['_concat', '@ember/helper', 'concat'], + ['_uniqueId', '@ember/helper', 'uniqueId'], // @ember/object ['Object', '@ember/object', 'default'],