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

fix tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-12-20 14:01:06 +02:00
parent 6925d879c4
commit 29a2158e3d
2 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,7 @@ jest.mock("chokidar", () => ({
jest.mock("../extension-installer", () => ({ jest.mock("../extension-installer", () => ({
extensionInstaller: { extensionInstaller: {
extensionPackagesRoot: "", extensionPackagesRoot: "",
installPackages: jest.fn() installPackage: jest.fn()
} }
})); }));
@ -41,7 +41,7 @@ describe("ExtensionDiscovery", () => {
// Need to force isLoaded to be true so that the file watching is started // Need to force isLoaded to be true so that the file watching is started
extensionDiscovery.isLoaded = true; extensionDiscovery.isLoaded = true;
await extensionDiscovery.initMain(); await extensionDiscovery.watchExtensions();
extensionDiscovery.events.on("add", (extension: InstalledExtension) => { extensionDiscovery.events.on("add", (extension: InstalledExtension) => {
expect(extension).toEqual({ expect(extension).toEqual({
@ -81,7 +81,7 @@ describe("ExtensionDiscovery", () => {
// Need to force isLoaded to be true so that the file watching is started // Need to force isLoaded to be true so that the file watching is started
extensionDiscovery.isLoaded = true; extensionDiscovery.isLoaded = true;
await extensionDiscovery.initMain(); await extensionDiscovery.watchExtensions();
const onAdd = jest.fn(); const onAdd = jest.fn();

View File

@ -170,7 +170,7 @@ export class ExtensionDiscovery {
await this.removeSymlinkByManifestPath(manifestPath); await this.removeSymlinkByManifestPath(manifestPath);
// Install dependencies for the new extension // Install dependencies for the new extension
await extensionInstaller.installPackage(extension.absolutePath); await this.installPackage(extension.absolutePath);
this.extensions.set(extension.id, extension); this.extensions.set(extension.id, extension);
logger.info(`${logModule} Added extension ${extension.manifest.name}`); logger.info(`${logModule} Added extension ${extension.manifest.name}`);
@ -369,6 +369,10 @@ export class ExtensionDiscovery {
return await extensionInstaller.installPackages(packageJsonPath, packagesJson); return await extensionInstaller.installPackages(packageJsonPath, packagesJson);
} }
async installPackage(name: string) {
return extensionInstaller.installPackage(name);
}
async loadBundledExtensions() { async loadBundledExtensions() {
const extensions: InstalledExtension[] = []; const extensions: InstalledExtension[] = [];
const folderPath = this.bundledFolderPath; const folderPath = this.bundledFolderPath;