mirror of
https://github.com/status-im/react-native.git
synced 2025-01-18 05:23:26 +00:00
1e626027f5
Summary: [Experimental API breaking changes] The notion of `parent` or `children` in navigaton is misleading. We have no intention to maintain or build the nested or hierarchical navigation states. To be clear, rename `navigationState.children` to `navigationState.route`. Reviewed By: ericvicenti Differential Revision: D3332115 fbshipit-source-id: c72ed08acaf030fb9c60abf22fb15cc0f44b3485
57 lines
1.4 KiB
JavaScript
57 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
|
|
.unmock('NavigationTabsReducer')
|
|
.unmock('NavigationFindReducer')
|
|
.unmock('NavigationStateUtils');
|
|
|
|
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.routes[0]).toBe('a');
|
|
expect(navState.routes[1]).toBe('b');
|
|
expect(navState.routes[2]).toBe('c');
|
|
expect(navState.routes.length).toBe(3);
|
|
expect(navState.index).toBe(1);
|
|
|
|
navState = reducer(
|
|
navState,
|
|
JumpToAction(2)
|
|
);
|
|
|
|
expect(navState.routes[0]).toEqual('a');
|
|
expect(navState.routes[1]).toEqual('b');
|
|
expect(navState.routes[2]).toEqual('c');
|
|
expect(navState.routes.length).toBe(3);
|
|
expect(navState.index).toBe(2);
|
|
});
|
|
|
|
});
|