"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var label_1 = require("./label");
var labelBackground_1 = require("./labelBackground");
jest.mock('./labelBackground', function () { return ({
    drawLabelBackground: jest.fn()
}); });
describe('drawLabel tests', function () {
    var context = {
        fillText: jest.fn()
    };
    var settings = {
        labelFont: 'Roboto',
        labelSize: 12,
        labelColor: {
            color: 'rgba(0, 0, 0, 0.87)'
        },
        labelWeight: 'normal'
    };
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should not call context.fillText if label is empty', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: ''
        };
        (0, label_1.drawLabel)(context, data, settings);
        expect(context.fillText).not.toHaveBeenCalled();
        expect(labelBackground_1.drawLabelBackground).not.toHaveBeenCalled();
    });
    it('should call context.fillText if label is not empty', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: 'Test label'
        };
        (0, label_1.drawLabel)(context, data, settings);
        expect(context.font).toBe('normal 12px Roboto');
        expect(context.fillStyle).toBe(settings.labelColor.color);
        expect(context.fillText).toHaveBeenCalledWith(data.label, 24, 5);
        expect(labelBackground_1.drawLabelBackground).toHaveBeenCalledWith(context, data, settings, {
            marginLeft: 2,
            lineHeight: settings.labelSize * 1.2
        });
    });
    it('should call drawLabelBackground to show background with specified color', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: 'Test label'
        };
        (0, label_1.drawLabel)(context, data, settings, { backgroundColor: '#FFF' });
        expect(labelBackground_1.drawLabelBackground).toHaveBeenCalledWith(context, data, settings, {
            backgroundColor: '#FFF',
            marginLeft: 2,
            lineHeight: settings.labelSize * 1.2
        });
        expect(context.fillText).toHaveBeenCalledWith(data.label, 24, 5);
    });
    it('should call drawLabelBackground with special background and margin in selected state', function () {
        var data = {
            x: 1,
            y: 1,
            size: 12,
            label: 'Test label',
            selected: true
        };
        (0, label_1.drawLabel)(context, data, settings);
        expect(labelBackground_1.drawLabelBackground).toHaveBeenCalledWith(context, data, settings, {
            backgroundColor: '#FFF',
            marginLeft: 6,
            lineHeight: settings.labelSize * 1.2
        });
        expect(context.fillText).toHaveBeenCalledWith(data.label, 28, 5);
    });
});
