message: Tested navigated handler accesses latest context
diff: import assert from 'assert';
  import mocha from 'mocha';
  import { StateNavigator } from 'navigation';
  -import { NavigationHandler } from 'navigation-react';
  +import { NavigationContext, NavigationHandler } from 'navigation-react';
  import { NavigationMotion, useSceneNavigated } from 'navigation-react-mobile';
  -import React, { useState } from 'react';
  +import React, { useState, useContext } from 'react';
  import ReactDOM from 'react-dom';
  import { act } from 'react-dom/test-utils';
  import { JSDOM } from 'jsdom';
  @@ -681,8 +681,8 @@ describe('UseSceneNavigated', function () {
  })
  });
  - describe('Navigated hook', function () {
  - it('should call updated handler', function(){
  + describe('Navigated handler', function () {
  + it('should access latest state', function(){
  var stateNavigator = new StateNavigator([
  { key: 'sceneA' }
  ]);
  @@ -721,4 +721,43 @@ describe('UseSceneNavigated', function () {
  }
  })
  });
  +
  + describe('Navigated handler', function () {
  + it('should access latest context', function(){
  + var stateNavigator = new StateNavigator([
  + { key: 'sceneA' }
  + ]);
  + stateNavigator.navigate('sceneA');
  + var {sceneA} = stateNavigator.states;
  + var oldState;
  + var SceneA = () => {
  + var navigationEvent = useContext(NavigationContext);
  + useSceneNavigated(() => {
  + var {stateContext} = navigationEvent.stateNavigator;
  + oldState = stateContext.oldState;
  + })
  + return <div />;
  + };
  + sceneA.renderScene = () => <SceneA />;
  + var container = document.createElement('div');
  + act(() => {
  + ReactDOM.render(
  + <NavigationHandler stateNavigator={stateNavigator}>
  + <NavigationMotion>
  + {(_style, scene, key) => <div key={key}>{scene}</div>}
  + </NavigationMotion>
  + </NavigationHandler>,
  + container
  + );
  + });
  + act(() => {
  + stateNavigator.navigate('sceneA');
  + });
  + try {
  + assert.equal(oldState, sceneA);
  + } finally {
  + ReactDOM.unmountComponentAtNode(container);
  + }
  + })
  + });
  });
  