-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
547afc0
commit bac4069
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
|
||
import React from 'react'; | ||
|
||
import makeRouteConfig from '../makeRouteConfig'; | ||
import Redirect from '../Redirect'; | ||
import Route from '../Route'; | ||
import RedirectObject from '../../Redirect'; | ||
|
||
|
||
const AppPage = () => <div>AppPage</div>; | ||
const MainPage = () => <div>MainPage</div>; | ||
const FooPage = () => <div>FooPage</div>; | ||
const BarPage = () => <div>BarPage</div>; | ||
|
||
|
||
it('works with a route', () => { | ||
expect(makeRouteConfig( | ||
<Route path="/" Component={AppPage} /> | ||
)).toEqual([ | ||
{ | ||
path: '/', | ||
Component: AppPage, | ||
}, | ||
]); | ||
}); | ||
|
||
it('works with nested layer', () => { | ||
expect(makeRouteConfig( | ||
<Route path="/" Component={AppPage}> | ||
<Route Component={MainPage} /> | ||
<Route path="foo" Component={FooPage}> | ||
<Route path="bar" Component={BarPage} /> | ||
</Route> | ||
</Route> | ||
)).toEqual([ | ||
{ | ||
path: '/', | ||
Component: AppPage, | ||
children: [ | ||
{ | ||
Component: MainPage, | ||
}, | ||
{ | ||
path: 'foo', | ||
Component: FooPage, | ||
children: [ | ||
{ | ||
path: 'bar', | ||
Component: BarPage, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
|
||
it('works with <Redirect>', () => { | ||
expect(makeRouteConfig( | ||
<Route | ||
path="/" | ||
Component={AppPage} | ||
> | ||
<Redirect | ||
from="widget/:widgetId" | ||
to="/widgets/:widgetId" | ||
/> | ||
</Route> | ||
)).toEqual([ | ||
{ | ||
path: '/', | ||
Component: AppPage, | ||
children: [ | ||
new RedirectObject({ | ||
from: 'widget/:widgetId', | ||
to: '/widgets/:widgetId', | ||
}), | ||
], | ||
}, | ||
]); | ||
}); |