"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getPackageVersion_1 = require("./getPackageVersion");
describe("getPackageVersion", () => {
    beforeEach(() => {
        jest.resetModules();
    });
    const packagePath = "../package.json";
    it("should return version without change when already valid", () => {
        const packageJSON = {
            version: "1.2.3",
        };
        jest.mock(packagePath, () => {
            return packageJSON;
        });
        const expected = "1.2.3";
        expect(getPackageVersion_1.getPackageVersion(packagePath)).toEqual(expected);
    });
    it("should return version with prefix", () => {
        const packageJSON = {
            version: "v1.2.3",
        };
        jest.mock(packagePath, () => {
            return packageJSON;
        });
        const expected = "v1.2.3";
        expect(getPackageVersion_1.getPackageVersion(packagePath)).toEqual(expected);
    });
    it("should return invalid version without change", () => {
        const packageJSON = {
            version: "a.b.c",
        };
        jest.mock(packagePath, () => {
            return packageJSON;
        });
        const expected = "a.b.c";
        expect(getPackageVersion_1.getPackageVersion(packagePath)).toEqual(expected);
    });
    it("should return invalid version without build metadata", () => {
        const packageJSON = {
            version: "a.b.c+asd1234",
        };
        jest.mock(packagePath, () => {
            return packageJSON;
        });
        const expected = "a.b.c";
        expect(getPackageVersion_1.getPackageVersion(packagePath)).toEqual(expected);
    });
    it("should return version without build metadata", () => {
        const packageJSON = {
            version: "1.2.3+asd1234",
        };
        jest.mock(packagePath, () => {
            return packageJSON;
        });
        const expected = "1.2.3";
        expect(getPackageVersion_1.getPackageVersion(packagePath)).toEqual(expected);
    });
    it("should return version with prefix but without build metadata", () => {
        const packageJSON = {
            version: "v1.2.3+asd1234",
        };
        jest.mock(packagePath, () => {
            return packageJSON;
        });
        const expected = "v1.2.3";
        expect(getPackageVersion_1.getPackageVersion(packagePath)).toEqual(expected);
    });
});
//# sourceMappingURL=data:application/json;base64,[encoded data, 5612 characters]