{"size": 1254, "ext": "js", "max_stars_repo_path": "assets/js/test-unit/theme/common/nod-functions/min-max-validate.spec.js", "max_stars_repo_name": "bibo72/BC-Grimentin2019", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/js/test-unit/theme/common/nod-functions/min-max-validate.spec.js", "max_issues_repo_name": "bibo72/BC-Grimentin2019", "max_issues_repo_issues_event_min_datetime": "2022-03-02T09:55:16.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-02T09:55:16.000Z", "max_forks_repo_path": "assets/js/test-unit/theme/common/nod-functions/min-max-validate.spec.js", "max_forks_repo_name": "bibo72/BC-Grimentin2019", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 27.2608695652, "max_line_length": 86, "alphanum_fraction": 0.5374800638}
import minMaxValidate from '../../../../theme/common/nod-functions/min-max-validate';
import $ from 'jquery';

describe('minMaxValidate', () => {
    let $max;
    let $min;
    let validateFn;
    let callback;

    beforeEach(() => {
        $min = $('<input id="min" type="number">').appendTo(document.body);
        $max = $('<input id="max" type="number">').appendTo(document.body);
        validateFn = minMaxValidate('#min', '#max');
        callback = jasmine.createSpy();
    });

    afterEach(() => {
        $max.remove();
        $min.remove();
    });

    it('should return false to validation callback if min > max', () => {
        $min.val(100);
        $max.val(10);
        validateFn(callback);

        expect(callback).toHaveBeenCalledWith(false);
    });

    it('should return false to validation callback if min == max', () => {
        $min.val(100);
        $max.val(100);
        validateFn(callback);

        expect(callback).toHaveBeenCalledWith(false);
    });

    it('should return true to validation callback if min < max', () => {
        $min.val(10);
        $max.val(100);
        validateFn(callback);

        expect(callback).toHaveBeenCalledWith(true);
    });
});
