import { getEdgeCenter } from './edgeLabelHelpers';
describe('getEdgeCenter tests', function () {
    var edgeId = 'edge1';
    var sourceId = 'source1';
    var targetId = 'target1';
    var sigma = {
        getEdgeDisplayData: jest.fn(),
        getNodeDisplayData: jest.fn(),
        framedGraphToViewport: jest.fn(),
        scaleSize: jest.fn(function (x) { return x; })
    };
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should calculate the regular edge center', function () {
        var edgeDisplayData = {
            loop: false
        };
        var sourceDisplayData = {
            x: 1,
            y: 2,
            size: 10
        };
        var targetDisplayData = {
            x: 3,
            y: 4
        };
        var expectedX = 2;
        var expectedY = 3;
        sigma.getEdgeDisplayData.mockReturnValue(edgeDisplayData);
        sigma.getNodeDisplayData.mockReturnValueOnce(sourceDisplayData);
        sigma.getNodeDisplayData.mockReturnValueOnce(targetDisplayData);
        sigma.framedGraphToViewport.mockImplementation(function (_a) {
            var x = _a.x, y = _a.y;
            return ({ x: x, y: y });
        });
        var result = getEdgeCenter(edgeId, sourceId, targetId, sigma);
        expect(result.x).toBe(expectedX);
        expect(result.y).toBe(expectedY);
        expect(sigma.getEdgeDisplayData).toHaveBeenCalledWith(edgeId);
        expect(sigma.getNodeDisplayData).toHaveBeenCalledWith(sourceId);
        expect(sigma.getNodeDisplayData).toHaveBeenCalledWith(targetId);
        expect(sigma.framedGraphToViewport).toHaveBeenCalledWith({ x: 1, y: 2 });
        expect(sigma.framedGraphToViewport).toHaveBeenCalledWith({ x: 3, y: 4 });
    });
    it('should calculate the edge center with loop', function () {
        var edgeDisplayData = {
            loop: true
        };
        var sourceDisplayData = {
            x: 100,
            y: 100,
            size: 10
        };
        var expectedX = 84.25;
        var expectedY = 115.75;
        sigma.getEdgeDisplayData.mockReturnValue(edgeDisplayData);
        sigma.getNodeDisplayData.mockReturnValueOnce(sourceDisplayData);
        sigma.getNodeDisplayData.mockReturnValueOnce(sourceDisplayData);
        sigma.framedGraphToViewport.mockImplementation(function (_a) {
            var x = _a.x, y = _a.y;
            return ({ x: x, y: y });
        });
        var result = getEdgeCenter(edgeId, sourceId, sourceId, sigma);
        expect(result.x).toBe(expectedX);
        expect(result.y).toBe(expectedY);
        expect(sigma.getEdgeDisplayData).toHaveBeenCalledWith(edgeId);
        expect(sigma.getNodeDisplayData).toHaveBeenCalledWith(sourceId);
        expect(sigma.framedGraphToViewport).toHaveBeenCalledWith({ x: 100, y: 100 });
        expect(sigma.scaleSize).toHaveBeenCalledWith(sourceDisplayData.size);
    });
});
