<commit_before>describe('The dataSelectionReducers factory', function () {
    let dataSelectionReducers,
        ACTIONS;

    const DEFAULT_STATE = {
        map: {
            baseLayer: 'topografie',
            overlays: [],
            viewCenter: [52.3719, 4.9012],
            zoom: 9,
            showActiveOverlays: false,
            isFullscreen: false,
            isLoading: false
        },
        layerSelection: {
            isEnabled: false
        },
        search: null,
        page: {
            name: 'home'
        },
        detail: null,
        straatbeeld: null,
        dataSelection: null,
        atlas: {
            isPrintMode: false
        }
    };

    beforeEach(function () {
        angular.mock.module('atlas');

        angular.mock.inject(function (_dataSelectionReducers_, _ACTIONS_) {
            dataSelectionReducers = _dataSelectionReducers_;
            ACTIONS = _ACTIONS_;
        });
    });

    describe('FETCH_DATA_SELECTION', function () {
        let payload;

        beforeEach(function () {
            payload = {
                dataset: 'bag',
                filters: {
                    buurtcombinatie: 'Geuzenbuurt',
                    buurt: 'Trompbuurt'
                },
                page: 1
            };
        });

        it('makes the map small (!isFullscreen), relevant when navigating via dp-dropdown-menu', () => {
            const mockedState = angular.copy(DEFAULT_STATE);
            mockedState.map.isFullscreen = true;

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.map.isFullscreen).toBe(false);
        });

        it('has a default table view', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                view: 'TABLE'
            }));
        });

        it('can display in list view', function () {
            const mockedState = angular.copy(DEFAULT_STATE);
            payload.view = 'LIST';

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                view: 'LIST'
            }));
        });

        it('sets the dataSelection dataset, filters and page', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                dataset: 'bag',
                filters: {
                    buurtcombinatie: 'Geuzenbuurt',
                    buurt: 'Trompbuurt'
                },
                page: 1
            }));
        });

        it('sets the dataSelection query', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            payload = 'zoek';

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                query: 'zoek'
            }));
        });

        it('makes the Array of markers empty', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                markers: []
            }));
        });

        it('sets isLoading to true', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection.isLoading).toBe(true);
        });

        it('disables search, page, detail and straatbeeld', function () {
            const mockedState = angular.copy(DEFAULT_STATE);
            mockedState.search = {some: 'object'};
            mockedState.page.name = 'somePage';
            mockedState.detail = {some: 'object'};
            mockedState.straatbeeld = {some: 'object'};

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);<commit_msg>added unit test tg-3218<commit_after>describe('The dataSelectionReducers factory', function () {
    let dataSelectionReducers,
        ACTIONS;

    const DEFAULT_STATE = {
        map: {
            baseLayer: 'topografie',
            overlays: [],
            viewCenter: [52.3719, 4.9012],
            zoom: 9,
            showActiveOverlays: false,
            isFullscreen: false,
            isLoading: false
        },
        layerSelection: {
            isEnabled: false
        },
        search: null,
        page: {
            name: 'home'
        },
        detail: null,
        straatbeeld: null,
        dataSelection: null,
        atlas: {
            isPrintMode: false
        }
    };

    beforeEach(function () {
        angular.mock.module('atlas');

        angular.mock.inject(function (_dataSelectionReducers_, _ACTIONS_) {
            dataSelectionReducers = _dataSelectionReducers_;
            ACTIONS = _ACTIONS_;
        });
    });

    describe('FETCH_DATA_SELECTION', function () {
        let payload;

        beforeEach(function () {
            payload = {
                dataset: 'bag',
                filters: {
                    buurtcombinatie: 'Geuzenbuurt',
                    buurt: 'Trompbuurt'
                },
                page: 1
            };
        });

        it('makes the map small (!isFullscreen), relevant when navigating via dp-dropdown-menu', () => {
            const mockedState = angular.copy(DEFAULT_STATE);
            mockedState.map.isFullscreen = true;

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.map.isFullscreen).toBe(false);
        });

        it('has a default table view', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                view: 'TABLE'
            }));
        });

        it('can display in list view', function () {
            const mockedState = angular.copy(DEFAULT_STATE);
            payload.view = 'LIST';

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                view: 'LIST'
            }));
        });

        it('sets the dataSelection dataset, filters and page', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                dataset: 'bag',
                filters: {
                    buurtcombinatie: 'Geuzenbuurt',
                    buurt: 'Trompbuurt'
                },
                page: 1
            }));
        });

        it('sets the dataSelection query', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            payload = 'zoek';

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                query: 'zoek'
            }));
            expect(output.dataSelection.filters).toEqual({});
        });

        it('makes the Array of markers empty', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection).toEqual(jasmine.objectContaining({
                markers: []
            }));
        });

        it('sets isLoading to true', function () {
            const mockedState = angular.copy(DEFAULT_STATE);

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);

            expect(output.dataSelection.isLoading).toBe(true);
        });

        it('disables search, page, detail and straatbeeld', function () {
            const mockedState = angular.copy(DEFAULT_STATE);
            mockedState.search = {some: 'object'};
            mockedState.page.name = 'somePage';
            mockedState.detail = {some: 'object'};
            mockedState.straatbeeld = {some: 'object'};

            const output = dataSelectionReducers[ACTIONS.FETCH_DATA_SELECTION.id](mockedState, payload);
{'fraction_non_alphanumeric': 0.10629139072847682, 'fraction_numerical': 0.003532008830022075, 'mean_word_length': 1.9106970767748153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3023367', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2380, 'n_words': 433}