Formatting and better type definitions

This commit is contained in:
Jannis Mattheis 2019-09-28 16:49:34 +02:00
parent 97d8837d0a
commit f90318205e
5 changed files with 15 additions and 9 deletions

View File

@ -107,9 +107,11 @@ export class CurrentUser {
await axios
.get(config.get('url') + 'client')
.then((resp: AxiosResponse<IClient[]>) => {
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);

View File

@ -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();

View File

@ -68,7 +68,7 @@ const hasReceivedMessage = async (title: RegExp, content: RegExp) => {
await waitForExists(page, selector.heading(), 'Plugins');
};
const inDetailPage = async (id: number, callback: (() => Promise<void>)) => {
const inDetailPage = async (id: number, callback: () => Promise<void>) => {
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);

View File

@ -60,7 +60,7 @@ export const newTest = async (pluginsDir = ''): Promise<GotifyTest> => {
};
};
const testPluginDir = (): {dir: string; generator: (() => string)} => {
const testPluginDir = (): {dir: string; generator: () => string} => {
const random = Math.random()
.toString(36)
.substring(2, 15);

View File

@ -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<string> => {
const element = await page.$(selector);
@ -25,7 +25,7 @@ export const count = async (page: Page, selector: string): Promise<number> => {
return page.$$(selector).then((elements) => elements.length);
};
export const waitToDisappear = async (page: Page, selector: string): Promise<void> => {
export const waitToDisappear = async (page: Page, selector: string): Promise<JSHandle> => {
return page.waitForFunction(
(_selector: string) => !document.querySelector(_selector),
{},
@ -33,7 +33,11 @@ export const waitToDisappear = async (page: Page, selector: string): Promise<voi
);
};
export const waitForCount = async (page: Page, selector: string, amount: number): Promise<void> => {
export const waitForCount = async (
page: Page,
selector: string,
amount: number
): Promise<JSHandle> => {
return page.waitForFunction(
(_selector: string, _amount: number) =>
document.querySelectorAll(_selector).length === _amount,