Merge branch 'main' into oss/merge-main-6e96676beb0b610a5d1f3f3ac53ffa0d9c0f9221

This commit is contained in:
lisbet-alvarez authored and GitHub committed 2023-06-05 14:54:49 -07:00
commit 0d12d61044
2 files changed
+7 -5

No files matched your search

@@ -2,8 +2,10 @@ import Helper from '@ember/component/helper';
import { inject as service } from '@ember/service';
export function indexedDisplayName(intl, translation, array, item) {
let index = array.indexOf(item) + 1;
if (index === 0) index = null;
const length = array.length;
let index = length - array.indexOf(item);
if (index > length) index = null;
return intl.t(translation, { index });
}
@@ -8,7 +8,7 @@ module('Integration | Helper | indexed-display-name', function (hooks) {
setupRenderingTest(hooks);
setupIntl(hooks);
test('it renders the resource name with its position in parent array', async function (assert) {
test('it renders the resource name with its position in parent array reversed', async function (assert) {
this.set('array', ['Boundary', 'is', 'cool!']);
await render(hbs`{{indexed-display-name
@@ -17,7 +17,7 @@ module('Integration | Helper | indexed-display-name', function (hooks) {
'Boundary'
}}`);
assert.dom(this.element).hasText('Connection 1');
assert.dom(this.element).hasText('Connection 3');
await render(hbs`{{indexed-display-name
'resources.session-recording.connection.title_index'
@@ -33,7 +33,7 @@ module('Integration | Helper | indexed-display-name', function (hooks) {
'cool!'
}}`);
assert.dom(this.element).hasText('Connection 3');
assert.dom(this.element).hasText('Connection 1');
});
test('it does not render the position if the index cannot be found', async function (assert) {