<commit_before>import { select } from 'redux-saga/effects';
import { testSaga } from 'redux-saga-test-plan';
import { mapBoundsEffect, requestMarkersEffect } from './data-selection';
import { getPage, hasUserAccesToPage } from '../../../store/redux-first-router/selectors';
import { fetchMarkersRequest, fetchMarkersSuccess } from '../../ducks/data-selection/actions';
import { getFiltersWithoutShape } from '../../ducks/filters/filters';
import { getDataset, getGeomarkersShape } from '../../ducks/data-selection/selectors';
import { getMapBoundingBox, getMapZoom } from '../../../map/ducks/map/selectors';
import { getMarkers } from '../../services/data-selection/data-selection-api';
import PAGES from '../../../app/pages';
import { waitForAuthentication } from '../user/user';

describe('data-selection sagas', () => {
  describe('mapBoundsEffect', () => {
    it('should only fetch markers if user on brk page', () => {
      testSaga(mapBoundsEffect, {})
        .next()
        .select(getPage)
        .next(PAGES.CADASTRAL_OBJECTS)
        .call(waitForAuthentication)
        .next()
        .select(hasUserAccesToPage)
        .next(true)
        .put(fetchMarkersRequest())
        .next()
        .isDone();

      testSaga(mapBoundsEffect, {})
        .next()
        .select(getPage)
        .next(PAGES.CADASTRAL_OBJECTS)
        .call(waitForAuthentication)
        .next()
        .select(hasUserAccesToPage)
        .next(false)
        .isDone();

      testSaga(mapBoundsEffect, {})
        .next()
        .select(getPage)
        .next(PAGES.ADDRESSES)
        .call(waitForAuthentication)
        .next()
        .select(hasUserAccesToPage)
        .next(true)
        .isDone();
    });
  });

  describe('requestMarkersEffect', () => {
    it('should successfully fetch markers', () => {
      testSaga(requestMarkersEffect, {})
        .next()
        .all([
          select(getFiltersWithoutShape),
          select(getDataset),
          select(getGeomarkersShape)
        ])
        .next([[], 'bag', {}])
        .select(getMapBoundingBox)
        .next([])
        .select(getMapZoom)
        .next(10)
        .call(getMarkers, 'bag', { shape: {} }, 10, [])
        .next('result')
        .put(fetchMarkersSuccess('result'))
        .next()
        .isDone();
    });
  });
});
<commit_msg>DP-6711 fix unittests saga<commit_after>import { select } from 'redux-saga/effects';
import { testSaga } from 'redux-saga-test-plan';
import { mapBoundsEffect, requestMarkersEffect } from './data-selection';
import { getPage, hasUserAccesToPage } from '../../../store/redux-first-router/selectors';
import { fetchMarkersRequest, fetchMarkersSuccess } from '../../ducks/data-selection/actions';
import { getFiltersWithoutShape } from '../../ducks/filters/filters';
import { getDataset, getGeomarkersShape } from '../../ducks/data-selection/selectors';
import { getMapZoom } from '../../../map/ducks/map/selectors';
import { getMarkers } from '../../services/data-selection/data-selection-api';
import PAGES from '../../../app/pages';
import { waitForAuthentication } from '../user/user';
import BOUNDING_BOX from '../../../map/services/bounding-box.constant';

describe('data-selection sagas', () => {
  describe('mapBoundsEffect', () => {
    it('should only fetch markers if user on brk page', () => {
      testSaga(mapBoundsEffect, {})
        .next()
        .select(getPage)
        .next(PAGES.CADASTRAL_OBJECTS)
        .call(waitForAuthentication)
        .next()
        .select(hasUserAccesToPage)
        .next(true)
        .put(fetchMarkersRequest())
        .next()
        .isDone();

      testSaga(mapBoundsEffect, {})
        .next()
        .select(getPage)
        .next(PAGES.CADASTRAL_OBJECTS)
        .call(waitForAuthentication)
        .next()
        .select(hasUserAccesToPage)
        .next(false)
        .isDone();

      testSaga(mapBoundsEffect, {})
        .next()
        .select(getPage)
        .next(PAGES.ADDRESSES)
        .call(waitForAuthentication)
        .next()
        .select(hasUserAccesToPage)
        .next(true)
        .isDone();
    });
  });

  describe('requestMarkersEffect', () => {
    it('should successfully fetch markers', () => {
      testSaga(requestMarkersEffect, {})
        .next()
        .all([
          select(getFiltersWithoutShape),
          select(getDataset),
          select(getGeomarkersShape)
        ])
        .next([[], 'bag', {}])
        .select(getMapZoom)
        .next(10)
        .call(getMarkers, 'bag', { shape: {} }, 10, BOUNDING_BOX.COORDINATES)
        .next('result')
        .put(fetchMarkersSuccess('result'))
        .next()
        .isDone();
    });
  });
});

{'fraction_non_alphanumeric': 0.167982924226254, 'fraction_numerical': 0.0025613660618996796, 'mean_word_length': 2.4154518950437316, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3867628', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1446, 'n_words': 235}