All files / msa2/src/test FakePositionStore.js

100% Statements 7/7
100% Branches 0/0
100% Functions 5/5
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                              7x 7x 7x             7x         7x       4x       4x          
/**
* Copyright 2018, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
 
import React, { Component } from 'react';
import PropTypes from 'prop-types';
 
import {
  omit,
} from 'lodash-es';
 
/**
 * Forwards all passed-in properties to an mocked `positionStore`
 *
 * Special properties:
 *  - `subscribe` (allows to overwrite the subscribe method of the mocked store)
 */
class FakePositionStore extends Component {
  constructor(props) {
    super(props);
    this.positionStore = {
      getState: () => ({
      ...omit(props, ["subscribe"]),
      }),
      subscribe: this.props.subscribe,
    };
  }
  getChildContext() {
    return {
      positionMSAStore: this.positionStore,
    };
  }
  render() {
    return this.props.children;
  }
}
 
FakePositionStore.defaultProps = {
  subscribe: () => {},
}
 
FakePositionStore.childContextTypes = {
  positionMSAStore: PropTypes.object,
};
 
export default FakePositionStore;