11import expect from 'expect' ;
22import React from 'react' ;
33import { createRoutesFromReactChildren } from '../RouteUtils' ;
4+ import IndexRoute from '../IndexRoute' ;
45import Route from '../Route' ;
56
67describe ( 'createRoutesFromReactChildren' , function ( ) {
@@ -28,10 +29,28 @@ describe('createRoutesFromReactChildren', function () {
2829 }
2930 } ) ;
3031
32+ it ( 'works with index routes' , function ( ) {
33+ var routes = createRoutesFromReactChildren (
34+ < Route path = "/" component = { Parent } >
35+ < IndexRoute component = { Hello } />
36+ </ Route >
37+ ) ;
38+
39+ expect ( routes ) . toEqual ( [
40+ {
41+ path : '/' ,
42+ component : Parent ,
43+ indexRoute : {
44+ component : Hello
45+ }
46+ }
47+ ] ) ;
48+ } ) ;
49+
3150 it ( 'works with nested routes' , function ( ) {
3251 var routes = createRoutesFromReactChildren (
3352 < Route component = { Parent } >
34- < Route path = "home" components = { { hello : Hello , goodbye : Goodbye } } />
53+ < Route path = "home" components = { { hello : Hello , goodbye : Goodbye } } />
3554 </ Route >
3655 ) ;
3756
@@ -50,9 +69,9 @@ describe('createRoutesFromReactChildren', function () {
5069
5170 it ( 'works with falsy children' , function ( ) {
5271 var routes = createRoutesFromReactChildren ( [
53- < Route path = "/one" component = { Parent } /> ,
72+ < Route path = "/one" component = { Parent } /> ,
5473 null ,
55- < Route path = "/two" component = { Parent } /> ,
74+ < Route path = "/two" component = { Parent } /> ,
5675 undefined
5776 ] ) ;
5877
@@ -71,7 +90,7 @@ describe('createRoutesFromReactChildren', function () {
7190 var routes = createRoutesFromReactChildren (
7291 < Route path = "/one" component = { Parent } >
7392 // This is a comment.
74- < Route path = "/two" component = { Hello } />
93+ < Route path = "/two" component = { Hello } />
7594 </ Route >
7695 ) ;
7796
0 commit comments