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:
parent
95b83b1ce6
commit
c5f3e1156f
@ -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");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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;
|
||||||
@ -83,10 +83,6 @@ export class LensExtension<
|
|||||||
|
|
||||||
get storeName() {
|
get storeName() {
|
||||||
return this.manifest.storeName;
|
return this.manifest.storeName;
|
||||||
}
|
|
||||||
|
|
||||||
get dataLocation() {
|
|
||||||
return this.storeName || this.id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get storeLocation() {
|
get storeLocation() {
|
||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user