mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix test, moving to object args notation to improve per-test readability
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
52d16df45b
commit
3dbdc407a6
@ -11,40 +11,54 @@ import type { LensExtensionManifest } from "../lens-extension";
|
|||||||
|
|
||||||
describe("Extension/App versions compatibility checks", () => {
|
describe("Extension/App versions compatibility checks", () => {
|
||||||
it("is compatible with exact version matching", () => {
|
it("is compatible with exact version matching", () => {
|
||||||
expect(isCompatible("5.5.0", "5.5.0")).toBeTruthy();
|
expect(isCompatible({ extLensEngineVersion: "5.5.0", appVersion: "5.5.0" })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is compatible with upper %PATCH versions of base app", () => {
|
it("is compatible with upper %PATCH versions of base app", () => {
|
||||||
expect(isCompatible("5.5.0", "5.5.5")).toBeTruthy();
|
expect(isCompatible({ extLensEngineVersion: "5.5.0", appVersion: "5.5.5" })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is compatible with higher %MINOR version of base app", () => {
|
it("is compatible with higher %MINOR version of base app", () => {
|
||||||
expect(isCompatible("5.5.0", "5.6.0")).toBeTruthy();
|
expect(isCompatible({ extLensEngineVersion: "5.5.0", appVersion: "5.6.0" })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is not compatible with higher %MAJOR version of base app", () => {
|
it("is not compatible with higher %MAJOR version of base app", () => {
|
||||||
expect(isCompatible("5.6.0", "6.0.0")).toBeFalsy(); // extension for lens@5 not compatible with lens@6
|
expect(isCompatible({ extLensEngineVersion: "5.6.0", appVersion: "6.0.0" })).toBeFalsy(); // extension for lens@5 not compatible with lens@6
|
||||||
expect(isCompatible("6.0.0", "5.6.0")).toBeFalsy();
|
expect(isCompatible({ extLensEngineVersion: "6.0.0", appVersion: "5.6.0" })).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is compatible with lensEngine with prerelease", () => {
|
it("is compatible with lensEngine with prerelease", () => {
|
||||||
expect(isCompatible("^5.4.0-alpha.0", "5.5.0-alpha.0")).toBeTruthy();
|
expect(isCompatible({
|
||||||
|
extLensEngineVersion: "^5.4.0-alpha.0",
|
||||||
|
appVersion: "5.5.0-alpha.0",
|
||||||
|
})).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports short version format for manifest.engines.lens", () => {
|
it("supports short version format for manifest.engines.lens", () => {
|
||||||
expect(isCompatible("5.5.0", "5.5")).toBeTruthy();
|
expect(isCompatible({ extLensEngineVersion: "5.5", appVersion: "5.5.1" })).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("throws for incorrect or not supported version format", () => {
|
it("throws for incorrect or not supported version format", () => {
|
||||||
expect(() => isCompatible(">=2.0", "2.0")).toThrow(/Invalid format/i);
|
expect(() => isCompatible({
|
||||||
expect(() => isCompatible("~2.0", "2.0")).toThrow(/Invalid format/i);
|
extLensEngineVersion: ">=2.0",
|
||||||
expect(() => isCompatible("*", "1.0")).toThrow(/Invalid format/i);
|
appVersion: "2.0",
|
||||||
|
})).toThrow(/Invalid format/i);
|
||||||
|
|
||||||
|
expect(() => isCompatible({
|
||||||
|
extLensEngineVersion: "~2.0",
|
||||||
|
appVersion: "2.0",
|
||||||
|
})).toThrow(/Invalid format/i);
|
||||||
|
|
||||||
|
expect(() => isCompatible({
|
||||||
|
extLensEngineVersion: "*",
|
||||||
|
appVersion: "1.0",
|
||||||
|
})).toThrow(/Invalid format/i);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function isCompatible(extensionLensEngine = "^1.0", appVersion = "1.0"): boolean {
|
function isCompatible({ extLensEngineVersion = "^1.0", appVersion = "1.0" } = {}): boolean {
|
||||||
const appSemVer = semver.coerce(appVersion);
|
const appSemVer = semver.coerce(appVersion);
|
||||||
const extensionManifestMock = getExtensionManifestMock(extensionLensEngine);
|
const extensionManifestMock = getExtensionManifestMock(extLensEngineVersion);
|
||||||
|
|
||||||
return isCompatibleExtension({ appSemVer })(extensionManifestMock);
|
return isCompatibleExtension({ appSemVer })(extensionManifestMock);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user