在测试中成对未触发时可观察到

问题描述

尝试测试使用成对的方法

方法


this.x$.pipe(pairwise()).subscribe((x) => {
      const [prevIoUs,current] = x;
      this.store.dispatch(actionThatIWantToFire({ appId: current }));
    });

用于演示目的。我知道我不需要成对。假装我知道。

测试:

it(
    `should dispatch`,waitForAsync(() => {
      const dispatchSpy = jest.spyOn(store,'dispatch');
      (component.x$ as Observable<any>) = cold('a---b|',{
        a: '123',b: '1234',});

      getTestScheduler().flush();
      expect(dispatchSpy).toHaveBeenCalledWith(
       actionThatIWantToFire,);
    }),);

但是订阅中的代码永远不会被调用调用它的唯一方法删除 pairwise。 有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)