"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var labelBackground_1 = require("./labelBackground");
describe('drawLabelBackground tests', function () {
    var context = {
        beginPath: jest.fn(),
        moveTo: jest.fn(),
        lineTo: jest.fn(),
        arc: jest.fn(),
        closePath: jest.fn(),
        fill: jest.fn(),
        measureText: jest.fn().mockReturnValue({
            width: 100
        }),
        fillText: jest.fn(),
        quadraticCurveTo: jest.fn(),
        stroke: jest.fn()
    };
    var settings = {
        labelFont: 'Roboto',
        labelSize: 12,
        labelColor: {
            color: 'rgba(0, 0, 0, 0.87)'
        },
        labelWeight: 'normal'
    };
    afterEach(function () {
        jest.clearAllMocks();
    });
    var get2DPathEventTypes = function (path) {
        return path._events.map(function (event) { return event.type; });
    };
    it('should call context methods if label is string (hover behavior)', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: 'Test label'
        };
        var canvasPath = (0, labelBackground_1.drawLabelBackground)(context, data, settings);
        var expectedEvents = [
            'moveTo',
            'quadraticCurveTo',
            'lineTo',
            'quadraticCurveTo',
            'lineTo',
            'quadraticCurveTo',
            'lineTo',
            'quadraticCurveTo',
            'closePath'
        ];
        expect(get2DPathEventTypes(canvasPath)).toEqual(expectedEvents);
        expect(context.fill).toHaveBeenCalledWith(canvasPath);
        expect(context.stroke).not.toHaveBeenCalled();
    });
    it('should not call context methods if label is not string', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: null
        };
        var canvasPath = (0, labelBackground_1.drawLabelBackground)(context, data, settings);
        expect(get2DPathEventTypes(canvasPath)).toEqual([]);
        expect(context.fill).not.toHaveBeenCalled();
        expect(context.stroke).not.toHaveBeenCalled();
    });
    it('should draw stroke if borderColor option is provided', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: 'Test label'
        };
        var canvasPath = (0, labelBackground_1.drawLabelBackground)(context, data, settings, { borderColor: 'red' });
        expect(context.strokeStyle).toEqual('red');
        var expectedEvents = [
            'moveTo',
            'quadraticCurveTo',
            'lineTo',
            'quadraticCurveTo',
            'lineTo',
            'quadraticCurveTo',
            'lineTo',
            'quadraticCurveTo',
            'closePath'
        ];
        expect(get2DPathEventTypes(canvasPath)).toEqual(expectedEvents);
        expect(context.fill).toHaveBeenCalledWith(canvasPath);
        expect(context.stroke).toHaveBeenCalledWith(canvasPath);
    });
});
