/**
 * DevExtreme (cjs/__internal/scheduler/options_validator/validator_rules.test.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
var validationFunctions = _interopRequireWildcard(require("./common/validation_functions"));
var _validator_rules = require("./validator_rules");

function _getRequireWildcardCache(nodeInterop) {
    if ("function" !== typeof WeakMap) {
        return null
    }
    var cacheBabelInterop = new WeakMap;
    var cacheNodeInterop = new WeakMap;
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop
    })(nodeInterop)
}

function _interopRequireWildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj
    }
    if (null === obj || "object" !== typeof obj && "function" !== typeof obj) {
        return {
            default: obj
        }
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj)
    }
    var newObj = {};
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for (var key in obj) {
        if ("default" !== key && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc)
            } else {
                newObj[key] = obj[key]
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj)
    }
    return newObj
}
describe("endDayHourMustBeGreaterThanStartDayHour", () => {
    const options = {
        startDayHour: 0,
        endDayHour: 24
    };
    let mock = null;
    beforeEach(() => {
        mock = jest.spyOn(validationFunctions, "greaterThan")
    });
    afterEach(() => {
        null === mock || void 0 === mock ? void 0 : mock.mockReset()
    });
    it("should call greaterThan function", () => {
        (0, _validator_rules.endDayHourMustBeGreaterThanStartDayHour)(options);
        expect(mock).toHaveBeenCalledWith(options.endDayHour, options.startDayHour)
    });
    it("should return true if valid", () => {
        null === mock || void 0 === mock ? void 0 : mock.mockImplementation(() => true);
        const result = (0, _validator_rules.endDayHourMustBeGreaterThanStartDayHour)(options);
        expect(result).toBe(true)
    });
    it("should return error (string) if invalid", () => {
        null === mock || void 0 === mock ? void 0 : mock.mockImplementation(() => false);
        const result = (0, _validator_rules.endDayHourMustBeGreaterThanStartDayHour)({
            startDayHour: 10,
            endDayHour: 9
        });
        expect(result).toBe("endDayHour: 9 must be greater that startDayHour: 10.")
    });
    it("should be the function with the correct name", () => {
        const func = _validator_rules.endDayHourMustBeGreaterThanStartDayHour;
        expect(func.name).toBe("endDayHourGreaterThanStartDayHour")
    })
});
describe("visibleIntervalMustBeDivisibleByCellDuration", () => {
    const options = {
        cellDuration: 30,
        startDayHour: 0,
        endDayHour: 24
    };
    let mock = null;
    beforeEach(() => {
        mock = jest.spyOn(validationFunctions, "divisibleBy")
    });
    afterEach(() => {
        null === mock || void 0 === mock ? void 0 : mock.mockReset()
    });
    it("should call divisibleBy function with correct values", () => {
        (0, _validator_rules.visibleIntervalMustBeDivisibleByCellDuration)(options);
        expect(mock).toHaveBeenCalledWith(1440, options.cellDuration)
    });
    it("should return true if valid", () => {
        null === mock || void 0 === mock ? void 0 : mock.mockImplementation(() => true);
        const result = (0, _validator_rules.visibleIntervalMustBeDivisibleByCellDuration)(options);
        expect(result).toBe(true)
    });
    it("should return error (string) if invalid", () => {
        null === mock || void 0 === mock ? void 0 : mock.mockImplementation(() => false);
        const result = (0, _validator_rules.visibleIntervalMustBeDivisibleByCellDuration)({
            cellDuration: 31,
            startDayHour: 9,
            endDayHour: 10
        });
        expect(result).toBe("endDayHour - startDayHour: 60 (minutes), must be divisible by cellDuration: 31 (minutes).")
    });
    it("should be the function with the correct name", () => {
        const func = _validator_rules.visibleIntervalMustBeDivisibleByCellDuration;
        expect(func.name).toBe("visibleIntervalMustBeDivisibleByCellDuration")
    })
});
describe("cellDurationMustBeLessThanVisibleInterval", () => {
    const options = {
        cellDuration: 30,
        startDayHour: 0,
        endDayHour: 24
    };
    let mock = null;
    beforeEach(() => {
        mock = jest.spyOn(validationFunctions, "lessThan")
    });
    afterEach(() => {
        null === mock || void 0 === mock ? void 0 : mock.mockReset()
    });
    it("should call divisibleBy function with correct values", () => {
        (0, _validator_rules.cellDurationMustBeLessThanVisibleInterval)(options);
        expect(mock).toHaveBeenCalledWith(options.cellDuration, 1440, false)
    });
    it("should return true if valid", () => {
        null === mock || void 0 === mock ? void 0 : mock.mockImplementation(() => true);
        const result = (0, _validator_rules.cellDurationMustBeLessThanVisibleInterval)(options);
        expect(result).toBe(true)
    });
    it("should return error (string) if invalid", () => {
        null === mock || void 0 === mock ? void 0 : mock.mockImplementation(() => false);
        const result = (0, _validator_rules.cellDurationMustBeLessThanVisibleInterval)({
            cellDuration: 120,
            startDayHour: 9,
            endDayHour: 10
        });
        expect(result).toBe("endDayHour - startDayHour: 60 (minutes), must be greater or equal the cellDuration: 120 (minutes).")
    });
    it("should be the function with the correct name", () => {
        const func = _validator_rules.cellDurationMustBeLessThanVisibleInterval;
        expect(func.name).toBe("cellDurationMustBeLessThanVisibleInterval")
    })
});
