"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const errors_1 = require("../types/errors");
const accessors_1 = require("./accessors");
describe('getArrayValue', () => {
    it('should return the correct value for a valid index', () => {
        const array = [1, 2, 3];
        expect((0, accessors_1.getArrayValue)(array, 1)).toBe(2);
    });
    it('should throw an error for an undefined array', () => {
        expect(() => (0, accessors_1.getArrayValue)(undefined, 1)).toThrow(errors_1.UnexpectedIndexError);
    });
    it('should throw an error for an out-of-bounds index', () => {
        const array = [1, 2, 3];
        expect(() => (0, accessors_1.getArrayValue)(array, 5)).toThrow(errors_1.UnexpectedIndexError);
    });
});
describe('getObjectValue', () => {
    it('should return the correct value for a valid key', () => {
        const obj = { a: 1, b: 2 };
        expect((0, accessors_1.getObjectValue)(obj, 'b')).toBe(2);
    });
    it('should throw an error for an undefined object', () => {
        expect(() => (0, accessors_1.getObjectValue)(undefined, 'a')).toThrow(errors_1.UnexpectedIndexError);
    });
    it('should throw an error for a non-existent key', () => {
        const obj = { a: 1, b: 2 };
        expect(() => (0, accessors_1.getObjectValue)(obj, 'c')).toThrow(errors_1.UnexpectedIndexError);
    });
});
describe('hasProperty', () => {
    it('should return true if the object has the property', () => {
        const obj = { scope: 'value' };
        expect((0, accessors_1.hasProperty)(obj, 'scope')).toBe(true);
    });
    it('should return false if the object does not have the property', () => {
        const obj = { other: 'value' };
        expect((0, accessors_1.hasProperty)(obj, 'scope')).toBe(false);
    });
    it('should return false for non-object types', () => {
        expect((0, accessors_1.hasProperty)(null, 'scope')).toBe(false);
        expect((0, accessors_1.hasProperty)(undefined, 'scope')).toBe(false);
        expect((0, accessors_1.hasProperty)(42, 'scope')).toBe(false);
        expect((0, accessors_1.hasProperty)('string', 'scope')).toBe(false);
    });
});
//# sourceMappingURL=accessors.test.js.map