首页 > 其他分享 >[Unit testing RxJS] Test synchronous operations

[Unit testing RxJS] Test synchronous operations

时间:2022-10-13 20:46:05浏览次数:46  
标签:operations const testScheduler testing synchronous rxjs expected

const { TestScheduler } = require("rxjs/testing");
const { map, take } = require("rxjs/operators");
const { concat, from } = require("rxjs");

describe("Marble testing in Rxjs", () => {
  let testScheduler;

  beforeEach(() => {
    testScheduler = new TestScheduler((actual, expected) => {
      expect(actual).toEqual(expected);
    });
  });

  it("should let you test asychronous operations", () => {
    testScheduler.run((helpers) => {
      const { expectObservable } = helpers;
      const source$ = from([1, 2, 3]);
      const expected = "(abc|)";
      expectObservable(source$).toBe(expected, { a: 1, b: 2, c: 3 });
    });
  });
});

 

标签:operations,const,testScheduler,testing,synchronous,rxjs,expected
From: https://www.cnblogs.com/Answer1215/p/16789569.html

相关文章