From 3f793a716fdab76d1a7beb8751a9b1a7cf2c416e Mon Sep 17 00:00:00 2001 From: TBraner Date: Wed, 10 Jul 2019 10:13:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fixed=20an=20issue=20with=20firs?= =?UTF-8?q?t=20route=20segments=20index-route=20lookup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addon/components/bread-crumbs.js | 6 ++++-- tests/acceptance/integration-test.js | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addon/components/bread-crumbs.js b/addon/components/bread-crumbs.js index aa6dc10..89d0fb5 100644 --- a/addon/components/bread-crumbs.js +++ b/addon/components/bread-crumbs.js @@ -28,6 +28,7 @@ export default Component.extend({ classNameBindings: ['breadCrumbClass'], hasBlock: bool('template').readOnly(), routing: service('-routing'), + routerService: service('router'), currentUrl: readOnly('applicationRoute.router.url'), currentRouteName: readOnly('applicationRoute.controller.currentRouteName'), @@ -68,8 +69,9 @@ export default Component.extend({ if (routes.length === 1) { let path = `${name}.index`; - - return (this._lookupRoute(path)) ? path : name; + + const isIndexRouteActive = this.get("routerService").isActive(path); + return (isIndexRouteActive) ? path : name; } return routes.join('.'); diff --git a/tests/acceptance/integration-test.js b/tests/acceptance/integration-test.js index 4c72240..2bad6a0 100644 --- a/tests/acceptance/integration-test.js +++ b/tests/acceptance/integration-test.js @@ -123,7 +123,7 @@ module('Acceptance | ember-crumbly integration test', function(hooks) { const listItems = await findAll('#customBlock li span'); assert.equal(currentRouteName(), 'animal.quadruped.cow.show', 'correct current route name'); - assert.equal(listItems[0].textContent, 'Animals at the Zoo', 'returns the right text'); + assert.equal(listItems[0].textContent, 'Derek Zoolander\'s Zoo for Animals Who Can\'t Read Good and Want to Do Other Stuff Good Too', 'returns the right text'); assert.equal(listItems[1].textContent, 'Cows', 'returns the right text'); assert.equal(listItems[2].textContent, 'Mary (5 years old)', 'returns the right text'); }); @@ -155,7 +155,7 @@ module('Acceptance | ember-crumbly integration test', function(hooks) { assert.equal(numberOfRenderedBreadCrumbs, 3, 'renders the correct number of breadcrumbs'); assert.deepEqual( $('#bootstrapLinkable li').map((idx, item) => item.innerText.trim()).toArray(), - ['I am Foo Index', 'I am Bar', 'I am Baz']); + ['I am Foo', 'I am Bar', 'I am Baz']); }); test('reverse option = TRUE renders breadcrumb from left to right', async function(assert) { @@ -166,7 +166,7 @@ module('Acceptance | ember-crumbly integration test', function(hooks) { assert.equal(numberOfRenderedBreadCrumbs, 3, 'renders the correct number of breadcrumbs'); assert.deepEqual( $('#reverseBootstrapLinkable li').map((idx, item) => item.innerText.trim()).toArray(), - ['I am Baz', 'I am Bar', 'I am Foo Index']); + ['I am Baz', 'I am Bar', 'I am Foo']); }); test('bread-crumbs component outputs crumbClass on li elements', async function(assert) {