How to use the redux-saga-test-plan.expectSaga function in redux-saga-test-plan

To help you get started, we’ve selected a few redux-saga-test-plan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github source-academy / cadet-frontend / src / sagas / __tests__ / workspaces.ts View on Github external
test('with error in the code, should return correct line number in error', () => {
      code = '// Prepend\n error';
      state = generateDefaultState(workspaceLocation, { editorPrepend: '// Prepend' });

      runInContext(code, context, { scheduler: 'preemptive', originalMaxExecTime: 1000 }).then(
        result => (context = (result as Finished).context)
      );

      const errors = context.errors.map((error: SourceError) => {
        const newError = cloneDeep(error);
        newError.location.start.line = newError.location.start.line - 1;
        newError.location.end.line = newError.location.end.line - 1;
        return newError;
      });

      return expectSaga(evalCode, code, context, execTime, workspaceLocation, actionType)
        .withState(state)
        .call(runInContext, code, context, {
          scheduler: 'preemptive',
          originalMaxExecTime: execTime
        })
        .put(actions.evalInterpreterError(errors, workspaceLocation))
        .silentRun();
    });
  });
github sovrin-foundation / connector-app / app / claim-offer / __tests__ / claim-offer-store.spec.js View on Github external
it('saga: saveSerializedClaimOffer', () => {
    const claimHandle = 1
    return expectSaga(
      saveSerializedClaimOffer,
      claimHandle,
      pairwiseConnection.identifier,
      uid
    )
      .provide([
        [
          matchers.call.fn(serializeClaimOffer, claimHandle),
          serializedClaimOffer,
        ],
        [
          matchers.call.fn(getClaimOfferState, claimHandle),
          claimOfferVcxInitialState,
        ],
      ])
      .put(
github sovrin-foundation / connector-app / app / lock / __tests__ / lock-store.spec.js View on Github external
it('check pin flow should work if correct pin is passed', () => {
    const pin = '123456'
    const salt = 'salt'
    const expectedPinHash = 'expectedPinHash'

    return expectSaga(checkPin, checkPinAction(pin))
      .provide([
        [matchers.call.fn(safeGet, IN_RECOVERY), null],
        [call(getHydrationItem, SALT), salt],
        [call(getHydrationItem, PIN_HASH), expectedPinHash],
        [matchers.call.fn(pinHash, pin, salt), expectedPinHash],
      ])
      .put(checkPinSuccess())
      .run()
  })
github source-academy / cadet-frontend / src / sagas / __tests__ / workspaces.ts View on Github external
test('loads CURVES library correctly', () => {
    const newExternalLibraryName = ExternalLibraryNames.CURVES;

    const symbols = externalLibraries.get(newExternalLibraryName)!;
    const library: Library = {
      chapter,
      external: {
        name: newExternalLibraryName,
        symbols
      },
      globals
    };

    return expectSaga(workspaceSaga)
      .put(actions.endClearContext(library, workspaceLocation))
      .dispatch({
        type: actionTypes.BEGIN_CLEAR_CONTEXT,
        payload: { library, workspaceLocation }
      })
      .silentRun()
      .then(() => {
        expect(loadLib).toHaveBeenCalledWith('CURVES');
        expect(getReadyWebGLForCanvas).toHaveBeenCalledWith('curve');
        globals.forEach(item => {
          expect(window[item[0]]).toEqual(item[1]);
        });
      });
  });
});
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / statements / statements.sagas.spec.ts View on Github external
it("returns error on failed request", () => {
      const error = new Error("Failed request");
      expectSaga(requestStatementsSaga)
        .provide([[matchers.call.fn(getStatements), throwError(error)]])
        .put(actions.failed(error))
        .withReducer(reducer)
        .hasFinalState({
          data: null,
          lastError: error,
          valid: false,
        })
        .run();
    });
  });
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / liveness / liveness.sagas.spec.ts View on Github external
it("successfully requests node liveness statuses", () => {
      expectSaga(requestLivenessSaga)
        .provide([[matchers.call.fn(getLiveness), livenessResponse]])
        .put(actions.received(livenessResponse))
        .withReducer(reducer)
        .hasFinalState({
          data: livenessResponse,
          lastError: null,
          valid: true,
        })
        .run();
    });