示例#1
0
  it("displays filter bar when button is clicked", () => {
    const store = setupStore([]);

    expect(getAllUi(store.getState()).filterBarVisible).toBe(false);

    const wrapper = mount(Provider({store}, FilterBar({})));
    wrapper.find(".devtools-filter-icon").simulate("click");

    expect(getAllUi(store.getState()).filterBarVisible).toBe(true);

    // Buttons are displayed
    const buttonProps = {
      active: true,
      dispatch: store.dispatch
    };
    const logButton = FilterButton(Object.assign({}, buttonProps,
      { label: "Logs", filterKey: MESSAGE_LEVEL.LOG }));
    const infoButton = FilterButton(Object.assign({}, buttonProps,
      { label: "Info", filterKey: MESSAGE_LEVEL.INFO }));
    const warnButton = FilterButton(Object.assign({}, buttonProps,
      { label: "Warnings", filterKey: MESSAGE_LEVEL.WARN }));
    const errorButton = FilterButton(Object.assign({}, buttonProps,
      { label: "Errors", filterKey: MESSAGE_LEVEL.ERROR }));
    expect(wrapper.contains([errorButton, warnButton, logButton, infoButton])).toBe(true);
  });
示例#2
0
 return (dispatch, getState) => {
   dispatch({
     type: FILTER_BAR_TOGGLE
   });
   const uiState = getAllUi(getState());
   Services.prefs.setBoolPref(PREFS.UI.FILTER_BAR, uiState.get("filterBarVisible"));
 };
示例#3
0
function mapStateToProps(state) {
  let uiState = getAllUi(state);
  return {
    filter: getAllFilters(state),
    filterBarVisible: uiState.filterBarVisible,
    persistLogs: uiState.persistLogs,
    filteredMessagesCount: getFilteredMessagesCount(state),
  };
}
示例#4
0
  it("displays filter bar when button is clicked", () => {
    const store = setupStore([]);

    expect(getAllUi(store.getState()).filterBarVisible).toBe(false);

    const wrapper = mount(Provider({store}, FilterBar({ serviceContainer })));
    wrapper.find(".devtools-filter-icon").simulate("click");

    expect(getAllUi(store.getState()).filterBarVisible).toBe(true);

    const secondaryBar = wrapper.find(".webconsole-filterbar-secondary");
    expect(secondaryBar.length).toBe(1);

    // Buttons are displayed
    const filterBtn = props => FilterButton(
      Object.assign({}, {
        active: true,
        dispatch: store.dispatch
      }, props)
    );

    let buttons = [
      filterBtn({ label: "Errors", filterKey: MESSAGE_LEVEL.ERROR }),
      filterBtn({ label: "Warnings", filterKey: MESSAGE_LEVEL.WARN }),
      filterBtn({ label: "Logs", filterKey: MESSAGE_LEVEL.LOG }),
      filterBtn({ label: "Info", filterKey: MESSAGE_LEVEL.INFO }),
      filterBtn({ label: "Debug", filterKey: MESSAGE_LEVEL.DEBUG }),
      DOM.span({
        className: "devtools-separator",
      }),
      filterBtn({ label: "CSS", filterKey: "css" }),
      filterBtn({ label: "XHR", filterKey: "netxhr", active: false }),
      filterBtn({ label: "Requests", filterKey: "net", active: false }),
    ];

    secondaryBar.children().forEach((child, index) => {
      expect(child.html()).toEqual(shallow(buttons[index]).html());
    });
  });
示例#5
0
function mapStateToProps(state) {
  return {
    filter: getAllFilters(state),
    ui: getAllUi(state)
  };
}