Tabnine Logo For Javascript
SagaTester.wasCalled
Code IndexAdd Tabnine to your IDE (free)

How to use
wasCalled
function
in
SagaTester

Best JavaScript code snippets using redux-saga-tester.SagaTester.wasCalled(Showing top 2 results out of 315)

origin: boris-pokorny/react-example

test("search saga", async () => {
 const delay = (t) => new Promise((res) => setTimeout(() => res(), t));
 const sagaTester = new SagaTester({
  initialState: {},
  reducers: {
   search: search,
  },
 });

 const mockSuccessResponse = {
  bestMatches: [],
 };
 const mockJsonPromise = Promise.resolve(mockSuccessResponse);
 const mockFetchPromise = Promise.resolve({
  json: () => mockJsonPromise,
 });
 jest.spyOn(global, "fetch").mockImplementation(() => mockFetchPromise);

 sagaTester.start(watchSearch);

 sagaTester.dispatch(searchSymbol("S"));
 expect(global.fetch).toHaveBeenCalledTimes(1);

 await delay(0);
 expect(global.fetch).toHaveBeenCalledTimes(1);
 expect(sagaTester.getState().search.options).toEqual([]);
 expect(sagaTester.wasCalled(types.SYMBOL_FOUND)).toEqual(true);
});
origin: boris-pokorny/react-example

test("prices saga", async () => {
 const delay = (t) => new Promise((res) => setTimeout(() => res(), t));
 const sagaTester = new SagaTester({
  initialState: {},
  reducers: {
   filter: filter,
   prices: prices,
  },
 });

 const mockSuccessResponse = {
  "Time Series": {},
 };
 const mockJsonPromise = Promise.resolve(mockSuccessResponse);
 const mockFetchPromise = Promise.resolve({
  json: () => mockJsonPromise,
 });
 jest.spyOn(global, "fetch").mockImplementation(() => mockFetchPromise);

 sagaTester.start(watchPrices);

 sagaTester.dispatch(fetchPrices());
 expect(sagaTester.getState().prices.loading).toEqual(true);
 expect(global.fetch).toHaveBeenCalledTimes(1);

 await delay(0);
 expect(global.fetch).toHaveBeenCalledTimes(1);
 expect(sagaTester.getState().prices.data.labels).toEqual([]);
 expect(sagaTester.wasCalled(types.PRICES_FETCHED)).toEqual(true);
});
redux-saga-tester(npm)SagaTesterwasCalled

Most used redux-saga-tester functions

  • SagaTester.dispatch
  • SagaTester.getState
  • SagaTester.start
  • SagaTester.wasCalled

Popular in JavaScript

  • rimraf
    A deep deletion module for node (like `rm -rf`)
  • async
    Higher-order functions and common patterns for asynchronous code
  • http
  • ws
    Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • js-yaml
    YAML 1.2 parser and serializer
  • lodash
    Lodash modular utilities.
  • minimist
    parse argument options
  • semver
    The semantic version parser used by npm.
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now