From f90318205e0bd306de1de523da9559248536a361 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sat, 28 Sep 2019 16:49:34 +0200 Subject: [PATCH] Formatting and better type definitions --- ui/src/CurrentUser.ts | 8 +++++--- ui/src/tests/message.test.ts | 2 +- ui/src/tests/plugin.test.ts | 2 +- ui/src/tests/setup.ts | 2 +- ui/src/tests/utils.ts | 10 +++++++--- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ui/src/CurrentUser.ts b/ui/src/CurrentUser.ts index 545cf2c..9963016 100644 --- a/ui/src/CurrentUser.ts +++ b/ui/src/CurrentUser.ts @@ -107,9 +107,11 @@ export class CurrentUser { await axios .get(config.get('url') + 'client') .then((resp: AxiosResponse) => { - resp.data.filter((client) => client.token === this.tokenCache).forEach((client) => { - return axios.delete(config.get('url') + 'client/' + client.id); - }); + resp.data + .filter((client) => client.token === this.tokenCache) + .forEach((client) => { + return axios.delete(config.get('url') + 'client/' + client.id); + }); }) .catch(() => Promise.resolve()); window.localStorage.removeItem(tokenKey); diff --git a/ui/src/tests/message.test.ts b/ui/src/tests/message.test.ts index 3093fa7..16b47b5 100644 --- a/ui/src/tests/message.test.ts +++ b/ui/src/tests/message.test.ts @@ -58,7 +58,7 @@ describe('Messages', () => { it('has no applications', async () => { expect(await count(page, `${naviId} .item`)).toBe(0); }); - describe('create apps', async () => { + describe('create apps', () => { it('Windows', async () => { windowsServerToken = await createApp('Windows'); await page.reload(); diff --git a/ui/src/tests/plugin.test.ts b/ui/src/tests/plugin.test.ts index ce7d5bb..fafbfb1 100644 --- a/ui/src/tests/plugin.test.ts +++ b/ui/src/tests/plugin.test.ts @@ -68,7 +68,7 @@ const hasReceivedMessage = async (title: RegExp, content: RegExp) => { await waitForExists(page, selector.heading(), 'Plugins'); }; -const inDetailPage = async (id: number, callback: (() => Promise)) => { +const inDetailPage = async (id: number, callback: () => Promise) => { const name = await innerText(page, $table.cell(id, Col.Name)); await page.click($table.cell(id, Col.Details)); await waitForExists(page, '.plugin-info .name > span', name); diff --git a/ui/src/tests/setup.ts b/ui/src/tests/setup.ts index b1234e1..265cc5f 100644 --- a/ui/src/tests/setup.ts +++ b/ui/src/tests/setup.ts @@ -60,7 +60,7 @@ export const newTest = async (pluginsDir = ''): Promise => { }; }; -const testPluginDir = (): {dir: string; generator: (() => string)} => { +const testPluginDir = (): {dir: string; generator: () => string} => { const random = Math.random() .toString(36) .substring(2, 15); diff --git a/ui/src/tests/utils.ts b/ui/src/tests/utils.ts index e9c0c02..27274a6 100644 --- a/ui/src/tests/utils.ts +++ b/ui/src/tests/utils.ts @@ -1,4 +1,4 @@ -import {ElementHandle, Page} from 'puppeteer'; +import {ElementHandle, JSHandle, Page} from 'puppeteer'; export const innerText = async (page: ElementHandle | Page, selector: string): Promise => { const element = await page.$(selector); @@ -25,7 +25,7 @@ export const count = async (page: Page, selector: string): Promise => { return page.$$(selector).then((elements) => elements.length); }; -export const waitToDisappear = async (page: Page, selector: string): Promise => { +export const waitToDisappear = async (page: Page, selector: string): Promise => { return page.waitForFunction( (_selector: string) => !document.querySelector(_selector), {}, @@ -33,7 +33,11 @@ export const waitToDisappear = async (page: Page, selector: string): Promise => { +export const waitForCount = async ( + page: Page, + selector: string, + amount: number +): Promise => { return page.waitForFunction( (_selector: string, _amount: number) => document.querySelectorAll(_selector).length === _amount,