Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async shouldExist(selector: string, log?: string) {
//const element = await this.app.client.element(selector);
const exists = await this.app.client.waitForExist(selector, 2 * 1000);
if (exists) {
// console.log(log ? log : `Found element matching '${selector}'`);
} else {
console.log(log ? log : `Could not find element matching '${selector}'`);
throw new Error(`Could not find element matching '${selector}'`);
}
expect(exists).toBe(true);
}
public async shouldNotExist(selector: string, log?: string) {
//const element = await this.app.client.element(selector);
const exists = await this.app.client.isExisting(selector);
// if (exists) {
// throw new Error(`Should not have found element matching '${selector}'`);
// }
expect(exists).toBe(false);
}
public async clickMenu(menuName: string, item: string) {
await delay(500);
const menu = await menuAddon.getMenuItem(menuName, item);
expect(menu).toBeTruthy();
//await this.app.electron.ipcRenderer.send("click-menu", [menuName, item]);
await menuAddon.clickMenu(menuName, item);
}
public async expectWindowTitle(title: string, log?: string) {
await delay(500);
const t = await this.app.browserWindow.getTitle();
expect(t).toBe(title);
}
it('should return an array of users', async () => {
const result = ['test'];
jest.spyOn(userService, 'findAll').mockImplementation(() => result);
expect(await userController.findAll()).toBe(result);
});
});