import isIdentical from '../isIdentical';

describe('Utils/Array/isIdentical', () => {
    test('throws exception for wrong argument types', () => {
        expect(() => isIdentical()).toThrowError();
        expect(() => isIdentical([])).toThrowError();
        expect(() => isIdentical(0, 0)).toThrowError();
        expect(() => isIdentical('foo', 'foo')).toThrowError();
    });
    test('returns true for the same array values', () => {
        expect(isIdentical([], [])).toBe(true);
        const testObj = {};
        const testArr = [];
        expect(isIdentical([1, 'foo', testObj, testArr], [1, 'foo', testObj, testArr])).toBe(true);
    });
    test('returns false for different array values', () => {
        expect(isIdentical([1], [2])).toBe(false);
        expect(isIdentical([{}], [{}])).toBe(false);
        expect(isIdentical([[]], [[]])).toBe(false);
        expect(isIdentical(['foo'], ['bar'])).toBe(false);
    });
    test('returns false if the order of items is different', () => {
        expect(isIdentical(['foo', 1], [1, 'foo'])).toBe(false);
    });
    test('returns false if the length is different', () => {
        expect(isIdentical(['foo'], ['foo', 1])).toBe(false);
    });
});
