chore: fix typecheck in tests

Change-Id: I3bdd94c3eb0e98ca360d72cbe82c5abaead4543c
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
Florent Benoit 2023-05-10 23:43:57 +02:00 committed by Florent BENOIT
parent 25371f74ed
commit 4b4a9897b2
9 changed files with 29 additions and 19 deletions

View file

@ -20,7 +20,8 @@ import { beforeAll, expect, expectTypeOf, test } from 'vitest';
import { CancellationTokenSource } from './cancellation-token';
import { CancellationTokenRegistry } from './cancellation-token-registry';
let cancellationTokenRegistry;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let cancellationTokenRegistry: any;
/* eslint-disable @typescript-eslint/no-empty-function */
beforeAll(() => {

View file

@ -20,7 +20,8 @@ import { beforeAll, beforeEach, expect, expectTypeOf, test, vi, vitest } from 'v
import { CancellationTokenImpl } from './cancellation-token';
import { CancellationTokenRegistry } from './cancellation-token-registry';
let cancellationTokenRegistry;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let cancellationTokenRegistry: any;
beforeEach(() => {
vi.clearAllMocks();

View file

@ -19,7 +19,7 @@
import { beforeEach, expect, test, vi } from 'vitest';
import { Certificates } from './certificates';
let certificate;
let certificate: Certificates;
const BEGIN_CERTIFICATE = '-----BEGIN CERTIFICATE-----';
const END_CERTIFICATE = '-----END CERTIFICATE-----';

View file

@ -26,8 +26,8 @@ vi.mock('./util', () => {
};
});
let closeBehavior;
let configurationRegistry;
let closeBehavior: CloseBehavior;
let configurationRegistry: ConfigurationRegistry;
beforeEach(() => {
configurationRegistry = new ConfigurationRegistry();

View file

@ -88,7 +88,8 @@ test('Create Kubernetes resources with v1 resource in error should return error'
const spy = vi.spyOn(client, 'createV1Resource').mockRejectedValue(new Error('V1Error'));
try {
await client.createResources('dummy', [{ apiVersion: 'v1', kind: 'Namespace' }]);
} catch (err) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
expect(spy).toBeCalled();
expect(err).to.be.a('Error');
expect(err.message).equal('V1Error');
@ -109,7 +110,8 @@ test('Create custom Kubernetes resources in error should return error', async ()
vi.spyOn(client, 'getPlural').mockReturnValue(Promise.resolve('namespaces'));
try {
await client.createResources('dummy', [{ apiVersion: 'group/v1', kind: 'Namespace' }]);
} catch (err) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
expect(spy).toBeCalled();
expect(err).to.be.a('Error');
expect(err.message).equal('CustomError');
@ -122,7 +124,8 @@ test('Create unknown custom Kubernetes resources should return error', async ()
const pluralSpy = vi.spyOn(client, 'getPlural').mockRejectedValue(new Error('CustomError'));
try {
await client.createResources('dummy', [{ apiVersion: 'group/v1', kind: 'Namespace' }]);
} catch (err) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
expect(createSpy).not.toBeCalled();
expect(pluralSpy).toBeCalled();
expect(err).to.be.a('Error');

View file

@ -20,7 +20,7 @@ import { beforeAll, beforeEach, expect, expectTypeOf, test, vi } from 'vitest';
import { MenuRegistry } from './menu-registry';
import { CommandRegistry } from './command-registry';
let menuRegistry;
let menuRegistry: MenuRegistry;
let commandRegistry;
/* eslint-disable @typescript-eslint/no-empty-function */

View file

@ -47,7 +47,8 @@ beforeEach(() => {
});
test('should initialize provider if there is kubernetes connection provider', async () => {
let providerInternalId;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let providerInternalId: any;
apiSenderSendMock.mockImplementation((message, data) => {
expect(message).toBe('provider-create');
@ -64,6 +65,7 @@ test('should initialize provider if there is kubernetes connection provider', as
});
expect(providerInternalId).toBeDefined();
await providerRegistry.initializeProvider(providerInternalId);
expect(telemetryTrackMock).toHaveBeenNthCalledWith(1, 'createProvider', {
@ -76,7 +78,8 @@ test('should initialize provider if there is kubernetes connection provider', as
});
test('should send version event if update', async () => {
let providerInternalId;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let providerInternalId: any;
apiSenderSendMock.mockImplementation((message, data) => {
expect(['provider-create', 'provider:update-version']).toContain(message);
@ -109,7 +112,8 @@ test('should send version event if update', async () => {
});
test('should initialize provider if there is container connection provider', async () => {
let providerInternalId;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let providerInternalId: any;
apiSenderSendMock.mockImplementation((message, data) => {
expect(message).toBe('provider-create');

View file

@ -39,7 +39,7 @@ test('expect correct parsing', async () => {
const command = '/bin/foo';
const commandArgs = ['bar', 'baz'];
const on: any = vi.fn().mockImplementationOnce((event: string, cb: (string) => string) => {
const on: any = vi.fn().mockImplementationOnce((event: string, cb: (arg0: string) => string) => {
if (event === 'data') {
cb(stdoutOutput);
}
@ -47,7 +47,7 @@ test('expect correct parsing', async () => {
vi.mocked(spawn).mockReturnValue({
stdout: { on, setEncoding: vi.fn() },
on: vi.fn().mockImplementation((event: string, cb: (number) => void) => {
on: vi.fn().mockImplementation((event: string, cb: (arg0: number) => void) => {
if (event === 'exit') {
cb(0);
}
@ -64,7 +64,7 @@ test('expect correct parsing', async () => {
test('expect do not fail if error', async () => {
const stdoutOutput = 'foo';
const on: any = vi.fn().mockImplementationOnce((event: string, cb: (string) => string) => {
const on: any = vi.fn().mockImplementationOnce((event: string, cb: (arg0: string) => string) => {
if (event === 'data') {
cb(stdoutOutput);
}
@ -72,7 +72,7 @@ test('expect do not fail if error', async () => {
vi.mocked(spawn).mockReturnValue({
stdout: { on, setEncoding: vi.fn() },
on: vi.fn().mockImplementation((event: string, cb: (number) => void) => {
on: vi.fn().mockImplementation((event: string, cb: (arg0: number) => void) => {
if (event === 'exit') {
cb(1);
}

View file

@ -27,10 +27,11 @@ import { TrayMenu } from './tray-menu';
import statusStopped from './assets/status-stopped.png';
let trayMenu: TrayMenu;
let tray;
let animatedTray;
let tray: Tray;
let animatedTray: AnimatedTray;
vi.mock('electron', async () => {
const Menu = vi.fn();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const Menu = {} as unknown as any;
Menu['buildFromTemplate'] = vi.fn();
return {
Menu,