@@ -153,10 +153,10 @@ export function test_PageLoaded_is_called_once() {
153153 var handler = function ( data ) {
154154 loaded ++ ;
155155 }
156-
156+
157157 var pageFactory = function ( ) : PageModule . Page {
158158 page1 = new PageModule . Page ( ) ;
159- addLabelToPage ( page1 , "Page 1" ) ;
159+ addLabelToPage ( page1 , "Page 1" ) ;
160160 return page1 ;
161161 } ;
162162
@@ -225,29 +225,36 @@ export var test_NavigateToNewPage = function () {
225225
226226export var test_PageNavigation_EventSequence = function ( ) {
227227 var testPage : PageModule . Page ;
228+ var context = { property : "this is the context" } ;
228229 var eventSequence = [ ] ;
229230 var pageFactory = function ( ) {
230231 testPage = new PageModule . Page ( ) ;
231232 addLabelToPage ( testPage ) ;
232- testPage . onNavigatingFrom = function ( ) {
233- eventSequence . push ( "onNavigatingFrom" ) ;
234- }
235-
236- testPage . onNavigatedFrom = function ( ) {
237- eventSequence . push ( "onNavigatedFrom" ) ;
238- }
239233
240- testPage . onNavigatingTo = function ( ) {
234+ testPage . on ( PageModule . Page . navigatingToEvent , function ( data : PageModule . NavigatedData ) {
241235 eventSequence . push ( "onNavigatingTo" ) ;
242- }
236+ TKUnit . assertEqual ( data . context , context , "onNavigatingTo: navigationContext" ) ;
237+ } ) ;
243238
244- testPage . onNavigatedTo = function ( ) {
239+ testPage . on ( PageModule . Page . navigatedToEvent , function ( data : PageModule . NavigatedData ) {
245240 eventSequence . push ( "onNavigatedTo" ) ;
246- }
241+ TKUnit . assertEqual ( data . context , context , "onNavigatedTo : navigationContext" ) ;
242+ } ) ;
243+
244+ testPage . on ( PageModule . Page . navigatingFromEvent , function ( data : PageModule . NavigatedData ) {
245+ eventSequence . push ( "onNavigatingFrom" ) ;
246+ TKUnit . assertEqual ( data . context , context , "onNavigatingFrom: navigationContext" ) ;
247+ } ) ;
248+
249+ testPage . on ( PageModule . Page . navigatedFromEvent , function ( data : PageModule . NavigatedData ) {
250+ eventSequence . push ( "onNavigatedFrom" ) ;
251+ TKUnit . assertEqual ( data . context , context , "onNavigatedFrom: navigationContext" ) ;
252+ } ) ;
253+
247254 return testPage ;
248255 } ;
249256
250- helper . navigate ( pageFactory ) ;
257+ helper . navigate ( pageFactory , context ) ;
251258 helper . goBack ( ) ;
252259
253260 var expectedEventSequence = [ "onNavigatingTo" , "onNavigatedTo" , "onNavigatingFrom" , "onNavigatedFrom" ] ;
@@ -263,9 +270,9 @@ export var test_NavigateTo_WithContext = function () {
263270 var testPage : PageModule . Page ;
264271 var pageFactory = function ( ) : PageModule . Page {
265272 testPage = new PageModule . Page ( ) ;
266- testPage . onNavigatedTo = function ( context ) {
273+ testPage . on ( PageModule . Page . navigatedToEvent , function ( ) {
267274 ////console.log(JSON.stringify(context));
268- }
275+ } ) ;
269276 return testPage ;
270277 } ;
271278 var navEntry = {
@@ -362,7 +369,7 @@ export var test_cssShouldBeAppliedToAllNestedElements = function () {
362369 } ;
363370
364371 helper . navigate ( pageFactory ) ;
365-
372+
366373 var expectedText = "Some text" ;
367374 try {
368375 TKUnit . assert ( label . style . backgroundColor . hex === "#ff00ff00" , "Expected: #ff00ff00, Actual: " + label . style . backgroundColor . hex ) ;
0 commit comments