Eric Vicenti a3085464f6 NavigationExperimental
Summary:
A new API to unify internal navigation. Also addresses a highly-rated community 'pain': https://productpains.com/post/react-native/better-navigator-api-and-docs/

Offers the following improvements:

- Redux-style navigation logic is easy to reason about
- Navigation state can be easily saved and restored through refreshes
- Declarative navigation views can be implemented in native or JS
- Animations and gestures are isolated and now use the Animated library

public

Reviewed By: hedgerwang

Differential Revision: D2798048

fb-gh-sync-id: 88027ef9ead8a80afa38354252bc377455cc6dbb
2016-02-05 14:26:35 -08:00

56 lines
1.4 KiB
JavaScript

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow-broken
*/
'use strict';
jest
.autoMockOff()
.mock('ErrorUtils');
const NavigationTabsReducer = require('NavigationTabsReducer');
const {
JumpToAction,
} = NavigationTabsReducer;
describe('NavigationTabsReducer', () => {
it('handles JumpTo with index', () => {
let reducer = NavigationTabsReducer({
tabReducers: [
(tabState, action) => tabState || 'a',
(tabState, action) => tabState || 'b',
(tabState, action) => tabState || 'c',
],
initialIndex: 1,
});
let navState = reducer();
expect(navState.children[0]).toBe('a');
expect(navState.children[1]).toBe('b');
expect(navState.children[2]).toBe('c');
expect(navState.children.length).toBe(3);
expect(navState.index).toBe(1);
navState = reducer(
navState,
JumpToAction(2)
);
expect(navState.children[0]).toEqual('a');
expect(navState.children[1]).toEqual('b');
expect(navState.children[2]).toEqual('c');
expect(navState.children.length).toBe(3);
expect(navState.index).toBe(2);
});
});