"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var react_hooks_1 = require("@testing-library/react-hooks");
var core_1 = require("@react-sigma/core");
var useSigmaCustomRenderers_1 = require("../../hooks/useSigmaCustomRenderers");
var useSelectedNodeRenderer_1 = require("./useSelectedNodeRenderer");
var defaultGraph_test_data_1 = require("./defaultGraph.test-data");
var nodeArc_1 = require("../../rendering/canvas/nodeArc");
jest.mock('@react-sigma/core');
jest.mock('../../hooks/useSigmaCustomRenderers', function () { return ({
    useSigmaCustomRenderers: jest.fn()
}); });
jest.mock('../../rendering/canvas/nodeArc', function () { return ({
    drawTwoArcs: jest.fn().mockImplementation(jest.requireActual('../../rendering/canvas/nodeArc').drawTwoArcs)
}); });
describe('useSelectedNodeRenderer tests', function () {
    var graph;
    var setUp = function (graphArg) {
        graph = graphArg || (0, defaultGraph_test_data_1.createDefaultGraph)();
        return (0, react_hooks_1.renderHook)(useSelectedNodeRenderer_1.useSelectedNodeRenderer, {
            initialProps: graph
        });
    };
    var getNodeDisplayData = jest.fn().mockImplementation(function (nodeId) { return graph.getNodeAttributes(nodeId); });
    var renderers = {};
    var addRenderers = function (rendererObject) { return Object.assign(renderers, rendererObject); };
    beforeEach(function () {
        useSigmaCustomRenderers_1.useSigmaCustomRenderers.mockReturnValue({
            addRenderers: addRenderers
        });
        core_1.useSigma.mockReturnValue({
            getNodeDisplayData: getNodeDisplayData,
            framedGraphToViewport: function (x) { return x; },
            scaleSize: function (x) { return x; }
        });
    });
    afterEach(function () {
        jest.clearAllMocks();
    });
    var getRenderer = function () { return renderers.selectedNodeBorder; };
    it('should not draw 2 arcs for regular node', function () {
        setUp();
        var renderer = getRenderer().renderer;
        var canvas = document.createElement('canvas');
        var canvasContext = canvas.getContext('2d');
        (0, react_hooks_1.act)(function () {
            renderer(canvasContext);
        });
        expect(nodeArc_1.drawTwoArcs).not.toHaveBeenCalled();
    });
    it('should draw 2 arcs for selected node', function () {
        var graph = (0, defaultGraph_test_data_1.createDefaultGraph)();
        graph.setNodeAttribute('hcp', 'selected', true);
        setUp(graph);
        var renderer = getRenderer().renderer;
        var canvas = document.createElement('canvas');
        var canvasContext = canvas.getContext('2d');
        (0, react_hooks_1.act)(function () {
            renderer(canvasContext);
        });
        expect(nodeArc_1.drawTwoArcs).toHaveBeenCalledTimes(1);
    });
});
