当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ActionsObservable.of方法代码示例

本文整理汇总了TypeScript中redux-observable.ActionsObservable.of方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ActionsObservable.of方法的具体用法?TypeScript ActionsObservable.of怎么用?TypeScript ActionsObservable.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redux-observable.ActionsObservable的用法示例。


在下文中一共展示了ActionsObservable.of方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('fetch$ epic', () => {
  const action$ = ActionsObservable.of({
    type: TodoAction.Constants.FETCH_TODOS,
  });

  it('dispatches the correct actions when successful', async () => {
    const mockResponse = mockData;
    const mockService = {
      fetchItems: () => Promise.resolve(mockResponse),
    };

    const expectedOutputActions = {
      type: TodoAction.Constants.SET_TODOS,
      payload: mockResponse,
    };

    const obs = fetch$(mockService)(action$);
    await expect(obs.toPromise()).resolves.toEqual(expectedOutputActions);
  });

  it('dispatches an error when the call fails', async () => {
    const mockService: Todo.Fetcher = {
      fetchItems: () => Promise.reject('error'),
    };

    const expectedOutputActions = {
      type: TodoAction.Constants.REQUEST_FAILED,
      payload: 'Fetch Failed',
    };

    const obs = fetch$(mockService)(action$);
    await expect(obs.toPromise()).resolves.toEqual(expectedOutputActions);
  });
});
开发者ID:ksaldana1,项目名称:react-native-typescript-todo,代码行数:34,代码来源:epics.ts

示例2: test

    test("and allows continuing", async () => {
      let registeredCallback;
      ipc.once = (event, callback) => {
        if (event === "show-message-box-response") {
          registeredCallback = callback;
        }
      };
      ipc.send = (event, data) => {
        expect(event).toBe("show-message-box");
        expect(data.message).toEqual(
          "Unsaved data will be lost. Are you sure you want to quit?"
        );

        // "Yes"
        registeredCallback("dummy-event", 0);
      };

      const state = buildState(true);
      const responses = await closeNotebookEpic(
        ActionsObservable.of(
          actions.closeNotebook({ contentRef: "contentRef1" })
        ),
        { value: state }
      )
        .pipe(toArray())
        .toPromise();

      expect(responses).toEqual([
        coreActions.killKernel({ kernelRef: "kernelRef1", restarting: false }),
        actions.closeNotebookProgress({
          newState: DESKTOP_NOTEBOOK_CLOSING_READY_TO_CLOSE
        })
      ]);
    });
开发者ID:nteract,项目名称:nteract,代码行数:34,代码来源:close-notebook.spec.ts

示例3: test

 test("returns an Observable with an initial state of idle", done => {
   const action$ = ActionsObservable.of({
     type: actionsModule.LAUNCH_KERNEL_SUCCESSFUL,
     payload: {
       kernel: {
         channels: of({
           header: { msg_type: "status" },
           content: { execution_state: "idle" }
         }) as Subject<any>,
         cwd: "/home/tester",
         type: "websocket"
       },
       kernelRef: "fakeKernelRef",
       contentRef: "fakeContentRef",
       selectNextKernel: false
     }
   });
   const obs = watchExecutionStateEpic(action$);
   obs.pipe(toArray()).subscribe(
     // Every action that goes through should get stuck on an array
     actions => {
       const types = actions.map(({ type }) => type);
       expect(types).toEqual([actionsModule.SET_EXECUTION_STATE]);
     },
     err => done.fail(err), // It should not error in the stream
     () => done()
   );
 });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:28,代码来源:kernel-lifecycle.spec.ts

示例4: test

 test("Informs about disconnected kernels, allows reconnection", async () => {
   const state$ = {
     value: {
       core: stateModule.makeStateRecord({
         kernelRef: "fake",
         entities: stateModule.makeEntitiesRecord({
           contents: stateModule.makeContentsRecord({
             byRef: Immutable.Map({
               fakeContent: stateModule.makeNotebookContentRecord()
             })
           }),
           kernels: stateModule.makeKernelsRecord({
             byRef: Immutable.Map({
               fake: stateModule.makeRemoteKernelRecord({
                 channels: null,
                 status: "not connected"
               })
             })
           })
         })
       }),
       app: {
         notificationSystem: { addNotification: jest.fn() }
       }
     }
   };
   const action$ = ActionsObservable.of(
     actions.executeCell({ id: "first", contentRef: "fakeContentRef" })
   );
   const responses = await executeCellEpic(action$, state$)
     .pipe(toArray())
     .toPromise();
   expect(responses).toEqual([]);
 });
开发者ID:nteract,项目名称:nteract,代码行数:34,代码来源:execute.spec.ts

示例5: test

  test("calls launchKernelObservable if given the correct action", async () => {
    const action$ = ActionsObservable.of(
      actionsModule.launchKernel({
        kernelSpec: { spec: "hokey", name: "woohoo" },
        contentRef: "abc",
        cwd: "~",
        selectNextKernel: true,
        kernelRef: "123"
      })
    );

    const state = {
      core: makeStateRecord(),
      app: {
        kernel: null
      }
    };

    const responses = await launchKernelEpic(action$, { value: state })
      .pipe(toArray())
      .toPromise();

    expect(responses[0]).toEqual(
      actionsModule.setKernelspecInfo({
        kernelInfo: { spec: "hokey", name: "woohoo" },
        contentRef: "abc"
      })
    );

    expect(responses[1]).toEqual(
      actionsModule.launchKernelSuccessful({
        kernel: {
          info: null,
          lastActivity: null,
          type: "zeromq",
          cwd: "~",
          hostRef: null,
          channels: expect.anything(),
          spawn: expect.anything(),
          connectionFile: "connectionFile.json",
          kernelSpecName: "woohoo",
          status: "launched"
        },
        selectNextKernel: true,
        contentRef: "abc",
        kernelRef: "123"
      })
    );

    expect(responses[2]).toEqual(
      actionsModule.setExecutionState({
        kernelStatus: "launched",
        kernelRef: "123"
      })
    );
  });
开发者ID:nteract,项目名称:nteract,代码行数:56,代码来源:kernel-launch.spec.ts

示例6: test

 test("invokes a SAVE_CONFIG when the SET_CONFIG_AT_KEY action happens", done => {
   const action$ = ActionsObservable.of({ type: "SET_CONFIG_AT_KEY" });
   const responseActions = saveConfigOnChangeEpic(action$);
   responseActions.subscribe(
     x => {
       expect(x).toEqual({ type: "SAVE_CONFIG" });
       done();
     },
     err => done.fail(err)
   );
 });
开发者ID:dalejung,项目名称:nteract,代码行数:11,代码来源:config.spec.ts


注:本文中的redux-observable.ActionsObservable.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。