1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Update extension id handling and tests after comments

Signed-off-by: Antti Lustila <antti.lustila@luotocompany.fi>
This commit is contained in:
Antti Lustila 2023-02-01 11:16:12 +02:00
parent 95b83b1ce6
commit c5f3e1156f
2 changed files with 52 additions and 8 deletions

View File

@ -18,7 +18,6 @@ describe("lens extension", () => {
name: "foo-bar", name: "foo-bar",
version: "0.1.1", version: "0.1.1",
engines: { lens: "^5.5.0" }, engines: { lens: "^5.5.0" },
storeName: "foo-bar-store",
}, },
id: "/this/is/fake/package.json", id: "/this/is/fake/package.json",
absolutePath: "/absolute/fake/", absolutePath: "/absolute/fake/",
@ -37,7 +36,56 @@ describe("lens extension", () => {
describe("storeName", () => { describe("storeName", () => {
it("returns storeName", () => { it("returns storeName", () => {
expect(ext.storeName).toBe("foo-bar-store"); expect(ext.storeName).not.toBeDefined();
});
});
describe("id", () => {
it("returns id", () => {
expect(ext.id).toBe("/this/is/fake/package.json");
});
});
describe("storeLocation", () => {
it("returns storeLocation", () => {
expect(ext.storeLocation).toBe("foo-bar");
});
});
});
describe("lens extension with storeName", () => {
beforeEach(async () => {
ext = new LensExtension({
manifest: {
name: "@lensapp/foo-bar",
storeName: "/test/foo-bar",
version: "0.1.1",
engines: { lens: "^5.5.0" },
},
id: "/this/is/fake/extension",
absolutePath: "/absolute/fake/",
manifestPath: "/this/is/fake/package.json",
isBundled: false,
isEnabled: true,
isCompatible: true,
});
});
describe("storeName", () => {
it("returns storeName", () => {
expect(ext.storeName).toBe("/test/foo-bar");
});
});
describe("id", () => {
it("derives id from storeName", () => {
expect(ext.id).toBe("/test/foo-bar");
});
});
describe("storeLocation", () => {
it("derives storeLocation from storeName", () => {
expect(ext.storeLocation).toBe("/test/foo-bar");
}); });
}); });
}); });

View File

@ -63,7 +63,7 @@ export class LensExtension<
constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) { constructor({ id, manifest, manifestPath, isBundled }: InstalledExtension) {
makeObservable(this); makeObservable(this);
this.id = id; this.id = manifest.storeName || id;
this.manifest = manifest; this.manifest = manifest;
this.manifestPath = manifestPath; this.manifestPath = manifestPath;
this.isBundled = !!isBundled; this.isBundled = !!isBundled;
@ -85,10 +85,6 @@ export class LensExtension<
return this.manifest.storeName; return this.manifest.storeName;
} }
get dataLocation() {
return this.storeName || this.id;
}
get storeLocation() { get storeLocation() {
return this.storeName || this.name; return this.storeName || this.name;
} }
@ -106,7 +102,7 @@ export class LensExtension<
* folder name. * folder name.
*/ */
async getExtensionFileFolder(): Promise<string> { async getExtensionFileFolder(): Promise<string> {
return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.dataLocation); return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.id);
} }
@action @action