如何测试使用 props 的 NgRx 选择器?

How to test NgRx selector which uses props?

我有以下选择器:

export const selectTableById = createSelector(selectRestaurantState, (state: RestaurantState, props) =>
  state.tables.find((table) => table.id === props.id)
);

它在调用时使用 props 向选择器添加附加信息。

在单元测试中我正在尝试这样的事情:

  it("should ...", () => {
    expect(selectTableById.projector(state, { props: { id: "id" } })).toEqual(...);
  });

但是我没有找到关于如何使用道具调用投影仪功能的信息

找到了:

const tables = ...
const state = <RestaurantState>{ tables };

it("should select table matched by id from props", () => {
    const props = { id: "t2" };
    expect(selectTableById.projector(state, props)).toEqual(tables[1]);
});

我的问题是,我在投影仪功能中添加了错误的状态(整个应用状态,而不仅仅是餐厅状态),而且道具格式不正确。