1+ import type { IBreadCrumbController } from '@nsf-open/ember-ui-foundation/constants' ;
2+ import type { TestContext } from '@ember/test-helpers' ;
3+
14import { module , test } from 'qunit' ;
25import { setupApplicationTest } from 'ember-qunit' ;
36import { visit } from '@ember/test-helpers' ;
47
58module ( 'Acceptance | Component | ui-bread-crumbs' , function ( hooks ) {
69 setupApplicationTest ( hooks ) ;
710
11+ function lookupController ( owner : TestContext [ 'owner' ] , fullName : string ) : IBreadCrumbController {
12+ return owner . lookup ( fullName ) as IBreadCrumbController ;
13+ }
14+
815 function nthCrumb ( idx : number , anchor = false ) {
916 return `.breadcrumb li:nth-child(${ idx } )${ anchor ? ' a' : '' } ` ;
1017 }
@@ -39,13 +46,13 @@ module('Acceptance | Component | ui-bread-crumbs', function (hooks) {
3946 } ) ;
4047
4148 test ( 'it does not render an empty ordered list' , async function ( assert ) {
42- this . owner . lookup ( 'controller:application' ) . breadCrumb = undefined ;
49+ lookupController ( this . owner , 'controller:application' ) . breadCrumb = undefined ;
4350 await visit ( '/' ) ;
4451 assert . dom ( '.breadcrumb' ) . doesNotExist ( ) ;
4552 } ) ;
4653
4754 test ( 'it filters out breadcrumbs with no label text' , async function ( assert ) {
48- this . owner . lookup ( 'controller:playground' ) . breadCrumb = { label : '' } ;
55+ lookupController ( this . owner , 'controller:playground' ) . breadCrumb = { label : '' } ;
4956
5057 await visit ( '/playground' ) ;
5158
@@ -54,14 +61,20 @@ module('Acceptance | Component | ui-bread-crumbs', function (hooks) {
5461 } ) ;
5562
5663 test ( 'it supports a breadcrumb being able to "rewind", to remove, prior crumbs' , async function ( assert ) {
57- this . owner . lookup ( 'controller:playground' ) . breadCrumb = { label : 'Foobar' , rewind : 1 } ;
64+ lookupController ( this . owner , 'controller:playground' ) . breadCrumb = {
65+ label : 'Foobar' ,
66+ rewind : 1 ,
67+ } ;
5868
5969 await visit ( '/playground' ) ;
6070
6171 assert . dom ( nthCrumb ( 1 ) ) . hasText ( 'Foobar' ) ;
6272 assert . dom ( nthCrumb ( 2 ) ) . doesNotExist ( ) ;
6373
64- this . owner . lookup ( 'controller:artists.artist' ) . breadCrumb = { label : 'Baz' , rewind : - 1 } ;
74+ lookupController ( this . owner , 'controller:artists.artist' ) . breadCrumb = {
75+ label : 'Baz' ,
76+ rewind : - 1 ,
77+ } ;
6578
6679 await visit ( '/artists/queen' ) ;
6780
@@ -70,8 +83,8 @@ module('Acceptance | Component | ui-bread-crumbs', function (hooks) {
7083 } ) ;
7184
7285 test ( 'it support a breadcrumb with fully custom href and target' , async function ( assert ) {
73- this . owner . lookup ( 'controller:playground' ) . breadCrumb = undefined ;
74- this . owner . lookup ( 'controller:playground' ) . breadCrumbs = [
86+ lookupController ( this . owner , 'controller:playground' ) . breadCrumb = undefined ;
87+ lookupController ( this . owner , 'controller:playground' ) . breadCrumbs = [
7588 { label : 'Search' , href : 'https://www.google.com' } ,
7689 { label : 'Playground' } ,
7790 ] ;
@@ -83,7 +96,7 @@ module('Acceptance | Component | ui-bread-crumbs', function (hooks) {
8396 assert . dom ( nthCrumb ( 2 , true ) ) . hasAttribute ( 'target' , '_self' ) ;
8497 assert . dom ( nthCrumb ( 4 ) ) . doesNotExist ( ) ;
8598
86- this . owner . lookup ( 'controller:artists' ) . breadCrumb = {
99+ lookupController ( this . owner , 'controller:artists' ) . breadCrumb = {
87100 label : 'Search More' ,
88101 href : 'https://www.bing.com' ,
89102 target : '_blank' ,
0 commit comments