import { renderHook, act } from '@testing-library/react';
import { useSigma } from '@react-sigma/core';
import { FAKE_CENTER_NODE_ID, useFakeCenterNode } from './useFakeCenterNode';
import { createDefaultGraph } from './defaultGraph.test-data';
jest.mock('@react-sigma/core', function () { return ({
    useSigma: jest.fn()
}); });
describe('useFakeCenterNode tests', function () {
    var graph, sigmaGraph;
    var setUp = function () {
        graph = createDefaultGraph();
        return renderHook(useFakeCenterNode, {
            initialProps: { graph: graph, timeout: 1000 }
        });
    };
    var sigma = {
        getGraph: jest.fn(function () { return sigmaGraph; })
    };
    beforeEach(function () {
        useSigma.mockReturnValue(sigma);
    });
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should add fake center node and edges on mount and drop it after timeout', function () {
        jest.useFakeTimers();
        setUp();
        expect(graph.hasNode(FAKE_CENTER_NODE_ID)).toBe(true);
        sigmaGraph = graph.copy();
        act(function () {
            jest.advanceTimersByTime(1000);
        });
        expect(graph.hasNode(FAKE_CENTER_NODE_ID)).toBe(false);
        jest.useRealTimers();
    });
});
