mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
added some unit tests / manifest.engines.lens semver compatibility check
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
8f356b8635
commit
22736de29a
65
src/extensions/__tests__/is-compatible-extension.test.ts
Normal file
65
src/extensions/__tests__/is-compatible-extension.test.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import semver from "semver";
|
||||||
|
import {
|
||||||
|
isCompatibleExtension,
|
||||||
|
} from "../extension-discovery/is-compatible-extension/is-compatible-extension";
|
||||||
|
import type { LensExtensionManifest } from "../lens-extension";
|
||||||
|
|
||||||
|
describe("Extension/App versions compatibility check", () => {
|
||||||
|
it("is compatible with exact version matching", () => {
|
||||||
|
expect(isCompatibleExtension({
|
||||||
|
appSemVer: semver.coerce("5.5.0"), // current app version
|
||||||
|
})(getExtensionManifestMock({
|
||||||
|
lensEngine: "5.5.0", // requested app version by extension ("semver"-format)
|
||||||
|
}))).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("is compatible with higher patch-versions of main app", () => {
|
||||||
|
expect(isCompatibleExtension({
|
||||||
|
appSemVer: semver.coerce("5.5.5"), // for patch-versions
|
||||||
|
})(getExtensionManifestMock({
|
||||||
|
lensEngine: "^5.5.0",
|
||||||
|
}))).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("supports short versions format for engines.lens", () => {
|
||||||
|
const isCompatible = isCompatibleExtension({
|
||||||
|
appSemVer: semver.coerce("5.5.0"),
|
||||||
|
})(getExtensionManifestMock({
|
||||||
|
lensEngine: "5.5",
|
||||||
|
}));
|
||||||
|
|
||||||
|
expect(isCompatible).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("supporting `manifest.engines.lens='*'` to match any base-app version", () => {
|
||||||
|
expect(isCompatibleExtension({
|
||||||
|
appSemVer: semver.coerce("1.0.0"),
|
||||||
|
})(getExtensionManifestMock({
|
||||||
|
lensEngine: "*",
|
||||||
|
}))).toBeTruthy();
|
||||||
|
|
||||||
|
expect(isCompatibleExtension({
|
||||||
|
appSemVer: semver.coerce("2.0.0"),
|
||||||
|
})(getExtensionManifestMock({
|
||||||
|
lensEngine: "*",
|
||||||
|
}))).toBeTruthy();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
function getExtensionManifestMock(
|
||||||
|
{
|
||||||
|
lensEngine = "1.0",
|
||||||
|
} = {}): LensExtensionManifest {
|
||||||
|
return {
|
||||||
|
name: "some-extension",
|
||||||
|
version: "1.0",
|
||||||
|
engines: {
|
||||||
|
lens: lensEngine,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user