import { resizeBackdrops } from './helpers';
describe('Popper helpers tests', function () {
    afterEach(function () {
        jest.restoreAllMocks();
    });
    describe('resizeBackdrops behavior', function () {
        var rafIdValue = 1;
        it('should calculate backdrop divs size and position and schedule requestAnimationFrame', function () {
            jest.spyOn(global, 'requestAnimationFrame').mockReturnValue(rafIdValue);
            var anchorEl = {
                getBoundingClientRect: function () { return ({ top: 100, left: 101, right: 200, bottom: 202 }); }
            }, leftBackdropRef = { current: { style: {} } }, rightBackdropRef = { current: { style: {} } }, topBackdropRef = { current: { style: {} } }, bottomBackdropRef = { current: { style: {} } }, rafIdRef = { current: null };
            resizeBackdrops({
                anchorEl: anchorEl,
                leftBackdropRef: leftBackdropRef,
                rightBackdropRef: rightBackdropRef,
                topBackdropRef: topBackdropRef,
                bottomBackdropRef: bottomBackdropRef,
                rafIdRef: rafIdRef
            });
            expect(topBackdropRef.current.style.top).toBe('0');
            expect(topBackdropRef.current.style.left).toBe('0');
            expect(topBackdropRef.current.style.right).toBe('0');
            expect(topBackdropRef.current.style.height).toBe('100px');
            expect(leftBackdropRef.current.style.top).toBe('0');
            expect(leftBackdropRef.current.style.left).toBe('0');
            expect(leftBackdropRef.current.style.width).toBe('101px');
            expect(leftBackdropRef.current.style.bottom).toBe('0');
            expect(rightBackdropRef.current.style.top).toBe('0');
            expect(rightBackdropRef.current.style.left).toBe('200px');
            expect(rightBackdropRef.current.style.right).toBe('0');
            expect(rightBackdropRef.current.style.bottom).toBe('0');
            expect(bottomBackdropRef.current.style.top).toBe('202px');
            expect(bottomBackdropRef.current.style.left).toBe('0');
            expect(bottomBackdropRef.current.style.right).toBe('0');
            expect(bottomBackdropRef.current.style.bottom).toBe('0');
            expect(rafIdRef.current).toBe(rafIdValue);
        });
        it('should just schedule requestAnimationFrame if throttling interval is not reached', function () {
            jest.spyOn(Date, 'now').mockReturnValue(12345);
            jest.spyOn(global, 'requestAnimationFrame').mockReturnValue(rafIdValue);
            var anchorEl = {
                getBoundingClientRect: function () { return ({ top: 100, left: 101, right: 200, bottom: 202 }); }
            }, leftBackdropRef = { current: { style: {} } }, rightBackdropRef = { current: { style: {} } }, topBackdropRef = { current: { style: {} } }, bottomBackdropRef = { current: { style: {} } }, rafIdRef = { current: null };
            resizeBackdrops({
                anchorEl: anchorEl,
                leftBackdropRef: leftBackdropRef,
                rightBackdropRef: rightBackdropRef,
                topBackdropRef: topBackdropRef,
                bottomBackdropRef: bottomBackdropRef,
                rafIdRef: rafIdRef,
                lastResizeTimestamp: 12346
            });
            expect(topBackdropRef.current.style.top).toBe(undefined);
            expect(topBackdropRef.current.style.left).toBe(undefined);
            expect(topBackdropRef.current.style.right).toBe(undefined);
            expect(topBackdropRef.current.style.height).toBe(undefined);
            expect(leftBackdropRef.current.style.top).toBe(undefined);
            expect(leftBackdropRef.current.style.left).toBe(undefined);
            expect(leftBackdropRef.current.style.width).toBe(undefined);
            expect(leftBackdropRef.current.style.bottom).toBe(undefined);
            expect(rightBackdropRef.current.style.top).toBe(undefined);
            expect(rightBackdropRef.current.style.left).toBe(undefined);
            expect(rightBackdropRef.current.style.right).toBe(undefined);
            expect(rightBackdropRef.current.style.bottom).toBe(undefined);
            expect(bottomBackdropRef.current.style.top).toBe(undefined);
            expect(bottomBackdropRef.current.style.left).toBe(undefined);
            expect(bottomBackdropRef.current.style.right).toBe(undefined);
            expect(bottomBackdropRef.current.style.bottom).toBe(undefined);
            expect(rafIdRef.current).toBe(rafIdValue);
        });
    });
});
