mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix unit tests and make tests fail if a promise rejects after the test harness is finishes (#2034)
This commit is contained in:
1 parent
a4ba77c58b
commit
503a49261e
15 files changed
+153
-166
No files matched your search
@@ -35,7 +35,8 @@ jest.mock("electron", () => {
|
||||
app: {
|
||||
getVersion: () => "99.99.99",
|
||||
getPath: () => "tmp",
|
||||
getLocale: () => "en"
|
||||
getLocale: () => "en",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
},
|
||||
ipcMain: {
|
||||
handle: jest.fn(),
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { SearchStore } from "../search-store";
|
||||
|
||||
let searchStore: SearchStore = null;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { Console } from "console";
|
||||
|
||||
console = new Console(process.stdout, process.stderr);
|
||||
|
||||
import mockFs from "mock-fs";
|
||||
|
||||
jest.mock("electron", () => {
|
||||
@@ -5,7 +9,8 @@ jest.mock("electron", () => {
|
||||
app: {
|
||||
getVersion: () => "99.99.99",
|
||||
getPath: () => "tmp",
|
||||
getLocale: () => "en"
|
||||
getLocale: () => "en",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -5,7 +5,8 @@ jest.mock("electron", () => {
|
||||
app: {
|
||||
getVersion: () => "99.99.99",
|
||||
getPath: () => "tmp",
|
||||
getLocale: () => "en"
|
||||
getLocale: () => "en",
|
||||
setLoginItemSettings: jest.fn(),
|
||||
},
|
||||
ipcMain: {
|
||||
handle: jest.fn(),
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface BaseStoreParams<T = any> extends ConfOptions<T> {
|
||||
* Note: T should only contain base JSON serializable types.
|
||||
*/
|
||||
export abstract class BaseStore<T = any> extends Singleton {
|
||||
protected storeConfig: Config<T>;
|
||||
protected storeConfig?: Config<T>;
|
||||
protected syncDisposers: Function[] = [];
|
||||
|
||||
whenLoaded = when(() => this.isLoaded);
|
||||
@@ -36,7 +36,7 @@ export abstract class BaseStore<T = any> extends Singleton {
|
||||
}
|
||||
|
||||
get name() {
|
||||
return path.basename(this.storeConfig.path);
|
||||
return path.basename(this.path);
|
||||
}
|
||||
|
||||
protected get syncRendererChannel() {
|
||||
@@ -48,7 +48,7 @@ export abstract class BaseStore<T = any> extends Singleton {
|
||||
}
|
||||
|
||||
get path() {
|
||||
return this.storeConfig.path;
|
||||
return this.storeConfig?.path || "";
|
||||
}
|
||||
|
||||
protected async init() {
|
||||
@@ -82,10 +82,13 @@ export abstract class BaseStore<T = any> extends Singleton {
|
||||
|
||||
protected async saveToFile(model: T) {
|
||||
logger.info(`[STORE]: SAVING ${this.path}`);
|
||||
|
||||
// todo: update when fixed https://github.com/sindresorhus/conf/issues/114
|
||||
Object.entries(model).forEach(([key, value]) => {
|
||||
this.storeConfig.set(key, value);
|
||||
});
|
||||
if (this.storeConfig) {
|
||||
for (const [key, value] of Object.entries(model)) {
|
||||
this.storeConfig.set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enableSync() {
|
||||
|
||||
Reference in new issue
Block a user