forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[added] onAbortedTransition, onActiveStateChange, onTransitionError R…
…outes props Also, removed Routes.handleAsyncError and Routes.handleCancelledTransition
- Loading branch information
Showing
4 changed files
with
212 additions
and
101 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
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
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,90 @@ | ||
require('./helper'); | ||
var URLStore = require('../modules/stores/URLStore'); | ||
var Route = require('../modules/components/Route'); | ||
var Routes = require('../modules/components/Routes'); | ||
|
||
describe('Routes', function() { | ||
|
||
afterEach(function() { | ||
URLStore.teardown(); | ||
window.location.hash = ''; | ||
}); | ||
|
||
describe('a change in active state', function () { | ||
it('triggers onActiveStateChange', function (done) { | ||
var App = React.createClass({ | ||
render: function () { | ||
return React.DOM.div(); | ||
} | ||
}); | ||
|
||
function handleActiveStateChange(state) { | ||
assert(state); | ||
removeComponent(routes); | ||
done(); | ||
} | ||
|
||
var routes = renderComponent( | ||
Routes({ onActiveStateChange: handleActiveStateChange }, | ||
Route({ handler: App }) | ||
) | ||
); | ||
}); | ||
}); | ||
|
||
describe('a cancelled transition', function () { | ||
it('triggers onCancelledTransition', function (done) { | ||
var App = React.createClass({ | ||
statics: { | ||
willTransitionTo: function (transition) { | ||
transition.abort(); | ||
} | ||
}, | ||
render: function () { | ||
return React.DOM.div(); | ||
} | ||
}); | ||
|
||
function handleCancelledTransition(transition) { | ||
assert(transition); | ||
removeComponent(routes); | ||
done(); | ||
} | ||
|
||
var routes = renderComponent( | ||
Routes({ onCancelledTransition: handleCancelledTransition }, | ||
Route({ handler: App }) | ||
) | ||
); | ||
}); | ||
}); | ||
|
||
describe('an error in a transition hook', function () { | ||
it('triggers onTransitionError', function (done) { | ||
var App = React.createClass({ | ||
statics: { | ||
willTransitionTo: function (transition) { | ||
throw new Error('boom!'); | ||
} | ||
}, | ||
render: function () { | ||
return React.DOM.div(); | ||
} | ||
}); | ||
|
||
function handleTransitionError(error) { | ||
assert(error); | ||
expect(error.message).toEqual('boom!'); | ||
removeComponent(routes); | ||
done(); | ||
} | ||
|
||
var routes = renderComponent( | ||
Routes({ onTransitionError: handleTransitionError }, | ||
Route({ handler: App }) | ||
) | ||
); | ||
}); | ||
}); | ||
|
||
}); |
Oops, something went wrong.