<commit_before>import {ResourcesState} from '../../../../../app/components/resources/state/resources-state';
import {OperationViews} from '../../../../../app/components/resources/state/operation-views';
import {Static} from '../../../static';


/**
 * @author <NAME>
 */
describe('ResourcesState', () => {

    const viewsList = [
        {
            'mainTypeLabel': 'Schnitt',
            'label': 'Ausgrabung',
            'operationSubtype': 'Trench',
            'name': 'excavation'
        }
    ];


    let resourcesState: ResourcesState;


    beforeEach(() => {

        const mockSerializer = jasmine.createSpyObj('serializer', ['store']);
        resourcesState = new ResourcesState(
            mockSerializer,
            new OperationViews(viewsList),
            undefined,
            undefined
        );

        resourcesState.loaded = true;
    });


    it('set type filters and q', () => {

        const trenchDocument1 = Static.ifDoc('trench1', 'trench1', 'Trench', 't1');
        const featureDocument1 = Static.ifDoc('Feature 1', 'feature1', 'Feature', 'feature1');
        featureDocument1.resource.relations['isRecordedIn'] = [trenchDocument1.resource.id];

        resourcesState.initialize('excavation');
        resourcesState.setMainTypeDocument(trenchDocument1.resource.id);

        resourcesState.setNavigationPathInternal({
            elements: [{
                document: featureDocument1, q: '', types: []
            }],
            rootDocument: featureDocument1, q: '', types: []
        });

        resourcesState.setTypeFilters(['Find']);
        resourcesState.setQueryString('abc');

        resourcesState.initialize('survey');
        expect(resourcesState.getTypeFilters()).toEqual([]);
        expect(resourcesState.getQueryString()).toEqual('');
        resourcesState.initialize('excavation');

        expect(resourcesState.getTypeFilters()).toEqual(['Find']);
        expect(resourcesState.getQueryString()).toEqual('abc');
    });


    it('delete type filter and q of segment', () => {

        const trenchDocument1 = Static.ifDoc('trench1', 'trench1', 'Trench', 't1');
        const featureDocument1 = Static.ifDoc('Feature 1', 'feature1', 'Feature', 'feature1');

        resourcesState.initialize('excavation');
        resourcesState.setMainTypeDocument(trenchDocument1.resource.id);

        resourcesState.setNavigationPathInternal({
            elements: [{
                document: featureDocument1,
                types: ['Find1'],
                q: 'abc'
            }],
            rootDocument: featureDocument1, q: '', types: []
        });
        resourcesState.setTypeFilters(undefined);
        resourcesState.setQueryString('');
        expect(resourcesState.getTypeFilters()).toEqual(undefined);
        expect(resourcesState.getQueryString()).toEqual('');
    });


    it('delete type filter and q of non segment', () => {

        const trenchDocument1 = Static.ifDoc('trench1', 'trench1', 'Trench', 't1');
        const featureDocument1 = Static.ifDoc('Feature 1', 'feature1', 'Feature', 'feature1');

        resourcesState.initialize('excavation');
        resourcesState.setMainTypeDocument(trenchDocument1.resource.id);

        resourcesState.setNavigationPathInternal({
            elements: [{
                document: featureDocument1, q: '', types: []
            }],
            types: ['Find1'],
            q: 'abc'
        });
        resourcesState.setTypeFilters(undefined);
        resourcesState.setQueryString('');
        expect(resourcesState.getTypeFilters()).toEqual(undefined);
        expect(resourcesState.getQueryString()).toEqual('');
    });
});
<commit_msg>fix unit tests<commit_after>import {ResourcesState} from '../../../../../app/components/resources/state/resources-state';
import {OperationViews} from '../../../../../app/components/resources/state/operation-views';
import {Static} from '../../../static';


/**
 * @author <NAME>
 */
describe('ResourcesState', () => {

    const viewsList = [
        {
            'mainTypeLabel': 'Schnitt',
            'label': 'Ausgrabung',
            'operationSubtype': 'Trench',
            'name': 'excavation'
        }
    ];


    let resourcesState: ResourcesState;


    beforeEach(() => {

        const mockSerializer = jasmine.createSpyObj('serializer', ['store']);
        resourcesState = new ResourcesState(
            mockSerializer,
            new OperationViews(viewsList),
            undefined,
            undefined
        );

        resourcesState.loaded = true;
    });


    it('set type filters and q', () => {

        const trenchDocument1 = Static.ifDoc('trench1', 'trench1', 'Trench', 't1');
        const featureDocument1 = Static.ifDoc('Feature 1', 'feature1', 'Feature', 'feature1');
        featureDocument1.resource.relations['isRecordedIn'] = [trenchDocument1.resource.id];

        resourcesState.initialize('excavation');
        resourcesState.setMainTypeDocument(trenchDocument1.resource.id);

        resourcesState.setNavigationPathInternal({
            elements: [{
                document: featureDocument1, q: '', types: []
            }],
            rootDocument: featureDocument1, qWithHierarchy: '', qWithoutHierarchy: '',
            typesWithHierarchy: [], typesWithoutHierarchy: [], displayHierarchy: true
        });

        resourcesState.setTypeFilters(['Find']);
        resourcesState.setQueryString('abc');

        resourcesState.initialize('survey');
        expect(resourcesState.getTypeFilters()).toEqual([]);
        expect(resourcesState.getQueryString()).toEqual('');
        resourcesState.initialize('excavation');

        expect(resourcesState.getTypeFilters()).toEqual(['Find']);
        expect(resourcesState.getQueryString()).toEqual('abc');
    });


    it('delete type filter and q of segment', () => {

        const trenchDocument1 = Static.ifDoc('trench1', 'trench1', 'Trench', 't1');
        const featureDocument1 = Static.ifDoc('Feature 1', 'feature1', 'Feature', 'feature1');

        resourcesState.initialize('excavation');
        resourcesState.setMainTypeDocument(trenchDocument1.resource.id);

        resourcesState.setNavigationPathInternal({
            elements: [{
                document: featureDocument1,
                types: ['Find1'],
                q: 'abc'
            }],
            rootDocument: featureDocument1,  qWithHierarchy: '', qWithoutHierarchy: '',
            typesWithHierarchy: [], typesWithoutHierarchy: [], displayHierarchy: true
        });
        resourcesState.setTypeFilters(undefined);
        resourcesState.setQueryString('');
        expect(resourcesState.getTypeFilters()).toEqual(undefined);
        expect(resourcesState.getQueryString()).toEqual('');
    });


    it('delete type filter and q of non segment', () => {

        const trenchDocument1 = Static.ifDoc('trench1', 'trench1', 'Trench', 't1');
        const featureDocument1 = Static.ifDoc('Feature 1', 'feature1', 'Feature', 'feature1');

        resourcesState.initialize('excavation');
        resourcesState.setMainTypeDocument(trenchDocument1.resource.id);

        resourcesState.setNavigationPathInternal({
            elements: [{
                document: featureDocument1, q: '', types: []
            }],
            qWithHierarchy: 'abc', qWithoutHierarchy: '',
            typesWithHierarchy: ['Find1'], typesWithoutHierarchy: [], displayHierarchy: true
        });
        resourcesState.setTypeFilters(undefined);
        resourcesState.setQueryString('');
        expect(resourcesState.getTypeFilters()).toEqual(undefined);
        expect(resourcesState.getQueryString()).toEqual('');
    });
});

{'fraction_non_alphanumeric': 0.14873665016931492, 'fraction_numerical': 0.00937744204219849, 'mean_word_length': 2.7096618357487925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4625562', 'n_tokens_mistral': 2022, 'n_tokens_neox': 1975, 'n_words': 330}