File tree Expand file tree Collapse file tree 4 files changed +85
-6
lines changed
sandbox/app/components/simple-list
tests/acceptance/sandbox/api Expand file tree Collapse file tree 4 files changed +85
-6
lines changed Original file line number Diff line number Diff line change @@ -84,26 +84,29 @@ const RESOLVED_TYPES = [
8484function generateResolvedTypeNavigationItems ( modules , type ) {
8585 let items = modules . map ( m => {
8686 let segments = m . file . split ( '/' ) ;
87- let fileName = segments . pop ( ) ;
87+ segments = segments . slice ( segments . indexOf ( type ) + 1 ) ;
8888
89- if ( type . match ( fileName ) ) {
90- fileName = segments . pop ( ) ;
89+ if ( type . match ( segments [ segments . length - 1 ] ) ) {
90+ segments . pop ( ) ;
9191 }
9292
93+ let path = segments . join ( '/' ) ;
9394 let name ;
95+
9496 if ( [ 'components' , 'helpers' ] . includes ( type ) ) {
95- name = `{{${ fileName } }}` ;
97+ name = `{{${ path } }}` ;
9698 } else {
99+ let fileName = segments . pop ( ) ;
97100 name = _ . upperFirst ( _ . camelCase ( fileName ) ) ;
98101 }
99102
100103 return {
101- path : `${ type } /${ fileName } ` ,
104+ path : `${ type } /${ path } ` ,
102105 name
103106 } ;
104107 } ) ;
105108
106- return _ . sortBy ( items , [ 'name ' ] ) ;
109+ return _ . sortBy ( items , [ 'path ' ] ) ;
107110}
108111
109112function generateModuleNavigationItems ( modules , type ) {
Original file line number Diff line number Diff line change 1+ /** @documenter esdoc */
2+
3+ import Component from '@ember/component' ;
4+ import { argument } from '@ember-decorators/argument' ;
5+ import { type } from '@ember-decorators/argument/type' ;
6+
7+ /**
8+ Pretty cool component, right?
9+
10+ To use it, you could enter the following in your template:
11+
12+ ```handlebars
13+ {{#simple-list items=(arr 1 2 3) as |item|}}
14+ {{#item as |value|}}
15+ {{value}}
16+ {{/item}}
17+ {{/simple-list}}
18+ ```
19+
20+ @yield {SimpleListItem} item
21+ */
22+ export default class SimpleList extends Component {
23+ /**
24+ The items for the list
25+ */
26+ @argument
27+ @type ( 'object' )
28+ items ;
29+ }
Original file line number Diff line number Diff line change 1+ /** @documenter esdoc */
2+
3+ import Component from '@ember/component' ;
4+ import { argument } from '@ember-decorators/argument' ;
5+ import { type } from '@ember-decorators/argument/type' ;
6+
7+ /**
8+ Pretty cool component, right?
9+
10+ To use it, you could enter the following in your template:
11+
12+ ```handlebars
13+ {{simple-list/item value=1}}
14+ ```
15+
16+ @yield {object} value
17+ */
18+ export default class SimpleListItem extends Component {
19+ /**
20+ The count
21+ */
22+ @argument
23+ @type ( 'object' )
24+ value ;
25+ }
Original file line number Diff line number Diff line change 1+ import { module , test } from 'qunit' ;
2+ import { setupApplicationTest } from 'ember-qunit' ;
3+ import setupMirage from 'ember-cli-mirage/test-support/setup-mirage' ;
4+ import { currentURL , visit } from '@ember/test-helpers' ;
5+
6+ import modulePage from '../../../pages/api/module' ;
7+
8+ module ( 'Acceptance | API | components' , function ( hooks ) {
9+ setupApplicationTest ( hooks ) ;
10+ setupMirage ( hooks ) ;
11+
12+ test ( 'nested components work' , async function ( assert ) {
13+ await visit ( '/sandbox' ) ;
14+ await modulePage . navItems . findOne ( { text : `{{simple-list}}` } ) . click ( ) ;
15+
16+ assert . equal ( currentURL ( ) , `/sandbox/api/components/simple-list` , 'correct url' ) ;
17+
18+ await modulePage . navItems . findOne ( { text : `{{simple-list/item}}` } ) . click ( ) ;
19+
20+ assert . equal ( currentURL ( ) , `/sandbox/api/components/simple-list/item` , 'correct url' ) ;
21+ } ) ;
22+ } ) ;
You can’t perform that action at this time.
0 commit comments