<commit_before>const { DomainSelector } = require('../components/domainSelector');

const util = require('../util.js');
jest.mock('../util.js', () => ({
    simVars: ({
        sortedTimestamps: [],
        rasters: ({
            1: {
                '2020': {'raster': {}}
            },
            2: {
                '2020': {'raster': {}},
                '2021': {'raster': {}}
            } 
        })
    })
}));

const controller = require('../components/Controller.js');
jest.mock('../components/Controller.js', () => ({
    controllers: ({
        domainInstance: ({
            subscribe: jest.fn(),
            getValue: () => [1, 2]
        }),
        currentDomain: ({
            getValue: jest.fn(),
            setValue: jest.fn()
        }),
    })
}));

describe('Domain Selector Tests', () => {
    var domainSelector;
    var currentDomain;

    beforeEach(async () => {
        controller.controllers.currentDomain.setValue = (newDomain) => currentDomain = newDomain;
        domainSelector = await document.body.appendChild(new DomainSelector());
    });

    test('Tests setUpForDomain', () => {
        domainSelector.setUpForDomain(1);

        expect(util.simVars.sortedTimestamps).toEqual(['2020']);
        expect(currentDomain).toEqual(1);<commit_msg>Fixes broken tests in domainSelector<commit_after>const { DomainSelector } = require('../components/domainSelector');

const util = require('../util.js');
jest.mock('../util.js', () => ({
    simVars: ({
        sortedTimestamps: [],
        rasters: ({
            1: {
                '2020': {'raster': {}}
            },
            2: {
                '2020': {'raster': {}},
                '2021': {'raster': {}}
            } 
        }),
        presets: ({ 
            opacity: "0.5"
        }),
    }),
    localToUTC: jest.fn()
}));

const controller = require('../components/Controller.js');
jest.mock('../components/Controller.js', () => ({
    controllers: ({
        domainInstance: ({
            subscribe: jest.fn(),
            getValue: () => [1, 2]
        }),
        currentDomain: ({
            getValue: jest.fn(),
            setValue: jest.fn()
        }),
        startDate: ({
            getValue: () => '2020',
            setValue: jest.fn()
        }),
        endDate: ({
            getValue: () => '2021',
            setValue: jest.fn()
        }),
        opacity: ({
            getValue: () => 0.5,
            setValue: jest.fn()
        })
    })
}));

describe('Domain Selector Tests', () => {
    var domainSelector;
    var currentDomain;

    beforeEach(async () => {
        controller.controllers.currentDomain.setValue = (newDomain) => currentDomain = newDomain;
        domainSelector = await document.body.appendChild(new DomainSelector());
    });

    test('Tests setUpForDomain', () => {
        domainSelector.setUpForDomain(1);

        expect(util.simVars.sortedTimestamps).toEqual(['2020']);
        expect(currentDomain).toEqual(1);
{'fraction_non_alphanumeric': 0.18047635021804764, 'fraction_numerical': 0.018785642401878563, 'mean_word_length': 1.8673076923076923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '6327564', 'n_tokens_mistral': 883, 'n_tokens_neox': 830, 'n_words': 133}