<commit_before>describe('Playground state service', function () {
    'use strict';

    var recipeStateMock, gridStateMock, filterStateMock;

    beforeEach(module('data-prep.services.state', function ($provide) {
        recipeStateMock = {};
        gridStateMock = {};
        filterStateMock = {};
        $provide.constant('recipeState', recipeStateMock);
        $provide.constant('gridState', gridStateMock);
        $provide.constant('filterState', filterStateMock);
    }));

    beforeEach(inject(function(GridStateService, FilterStateService, LookupStateService, SuggestionsStateService) {
        spyOn(GridStateService, 'setData').and.returnValue();
        spyOn(GridStateService, 'setFilter').and.returnValue();
        spyOn(GridStateService, 'reset').and.returnValue();
        spyOn(FilterStateService, 'addGridFilter').and.returnValue();
        spyOn(FilterStateService, 'updateGridFilter').and.returnValue();
        spyOn(FilterStateService, 'removeGridFilter').and.returnValue();
        spyOn(FilterStateService, 'removeAllGridFilters').and.returnValue();
        spyOn(FilterStateService, 'reset').and.returnValue();
        spyOn(LookupStateService, 'reset').and.returnValue();
        spyOn(SuggestionsStateService, 'reset').and.returnValue();
    }));

    describe('playground state', function() {
        it('should set dataset metadata in state', inject(function(playgroundState, PlaygroundStateService) {
            //given
            var dataset = {
               id: '958cb63f235e4565'
            };
            expect(playgroundState.dataset).not.toBe(dataset);

            //when
            PlaygroundStateService.setDataset(dataset);

            //then
            expect(playgroundState.dataset).toBe(dataset);
        }));

        it('should set data in state', inject(function(playgroundState, PlaygroundStateService) {
            //given
            expect(playgroundState.data).toBeFalsy();
            var data = {
               records: []
            };

            //when
            PlaygroundStateService.setData(data);

            //then
            expect(playgroundState.data).toBe(data);
        }));

        it('should set data in grid', inject(function(playgroundState, PlaygroundStateService, GridStateService) {
            //given
            expect(GridStateService.setData).not.toHaveBeenCalled();
            var data = {
               records: []
            };
            var filters = [{}, {}];
            filterStateMock.gridFilters = filters;

            //when
            PlaygroundStateService.setData(data);

            //then
            expect(GridStateService.setData).toHaveBeenCalledWith(data);
            expect(GridStateService.setFilter).toHaveBeenCalledWith(filters, data);
        }));

        it('should set preparation in state', inject(function(playgroundState, PlaygroundStateService) {
            //given
            expect(playgroundState.preparation).toBeFalsy();
            var preparation = {
                id: '3d245846bc46f51'
            };
<commit_msg>TDP-599 : move unit test in its own test (do not pollute existing tests that check other things)<commit_after>describe('Playground state service', function () {
    'use strict';

    var recipeStateMock, gridStateMock, filterStateMock;

    beforeEach(module('data-prep.services.state', function ($provide) {
        recipeStateMock = {};
        gridStateMock = {};
        filterStateMock = {};
        $provide.constant('recipeState', recipeStateMock);
        $provide.constant('gridState', gridStateMock);
        $provide.constant('filterState', filterStateMock);
    }));

    beforeEach(inject(function(GridStateService, FilterStateService, LookupStateService, SuggestionsStateService) {
        spyOn(GridStateService, 'setData').and.returnValue();
        spyOn(GridStateService, 'setFilter').and.returnValue();
        spyOn(GridStateService, 'reset').and.returnValue();
        spyOn(FilterStateService, 'addGridFilter').and.returnValue();
        spyOn(FilterStateService, 'updateGridFilter').and.returnValue();
        spyOn(FilterStateService, 'removeGridFilter').and.returnValue();
        spyOn(FilterStateService, 'removeAllGridFilters').and.returnValue();
        spyOn(FilterStateService, 'reset').and.returnValue();
        spyOn(LookupStateService, 'reset').and.returnValue();
        spyOn(SuggestionsStateService, 'reset').and.returnValue();
    }));

    describe('playground state', function() {
        it('should set dataset metadata in state', inject(function(playgroundState, PlaygroundStateService) {
            //given
            var dataset = {
               id: '958cb63f235e4565'
            };
            expect(playgroundState.dataset).not.toBe(dataset);

            //when
            PlaygroundStateService.setDataset(dataset);

            //then
            expect(playgroundState.dataset).toBe(dataset);
        }));

        it('should set data in state', inject(function(playgroundState, PlaygroundStateService) {
            //given
            expect(playgroundState.data).toBeFalsy();
            var data = {
               records: []
            };

            //when
            PlaygroundStateService.setData(data);

            //then
            expect(playgroundState.data).toBe(data);
        }));

        it('should set data in grid', inject(function(playgroundState, PlaygroundStateService, GridStateService) {
            //given
            expect(GridStateService.setData).not.toHaveBeenCalled();
            var data = {
               records: []
            };

            //when
            PlaygroundStateService.setData(data);

            //then
            expect(GridStateService.setData).toHaveBeenCalledWith(data);
        }));

        it('should set filters again on data change in grid to refresh statefull filters (ex: invalid filters)', inject(function(playgroundState, PlaygroundStateService, GridStateService) {
            //given
            expect(GridStateService.setData).not.toHaveBeenCalled();
            var data = {
               records: []
            };
            var filters = [{}, {}];
            filterStateMock.gridFilters = filters;

            //when
            PlaygroundStateService.setData(data);

            //then
            expect(GridStateService.setFilter).toHaveBeenCalledWith(filters, data);
        }));

        it('should set preparation in state', inject(function(playgroundState, PlaygroundStateService) {
            //given
            expect(playgroundState.preparation).toBeFalsy();
            var preparation = {
                id: '3d245846bc46f51'
            };

{'fraction_non_alphanumeric': 0.11692399940038975, 'fraction_numerical': 0.007345225603357817, 'mean_word_length': 2.4285714285714284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3633671', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1699, 'n_words': 281}