|
15 | 15 | * |
16 | 16 | * SPDX-License-Identifier: Apache-2.0 |
17 | 17 | ***********************************************************************/ |
| 18 | +/* eslint-disable @typescript-eslint/no-implicit-any */ |
| 19 | + |
| 20 | +import { ProgressOptions } from "@podman-desktop/api"; |
| 21 | +import { vi } from "vitest"; |
18 | 22 |
|
19 | 23 | /** |
20 | 24 | * Mock the extension API for vitest. |
21 | 25 | * This file is referenced from vitest.config.js file. |
22 | 26 | */ |
23 | | -const plugin = { |
24 | | - EventEmitter: vi.fn().mockImplementation(() => { |
25 | | - return { |
26 | | - fire: vi.fn(), |
27 | | - }; |
28 | | - }), |
29 | | - registry: { |
| 27 | + |
| 28 | +export const registry = { |
30 | 29 | suggestRegistry: vi.fn(), |
31 | 30 | unregisterRegistry: vi.fn(), |
32 | | - }, |
33 | | - authentication: { |
34 | | - registerAuthenticationProvider: vi.fn(), |
35 | | - getSession: vi.fn(), |
36 | | - onDidChangeSessions: vi.fn(), |
37 | | - }, |
38 | | - commands: { |
| 31 | + }; |
| 32 | +export const commands = { |
39 | 33 | registerCommand: vi.fn(), |
40 | 34 | executeCommand: vi.fn(), |
41 | | - }, |
42 | | - window: { |
43 | | - createStatusBarItem: () => ({ |
44 | | - show: vi.fn(), |
45 | | - iconClass: '', |
46 | | - }), |
47 | | - withProgress: (_options, callback) => { |
| 35 | + }; |
| 36 | +export const window = { |
| 37 | + createStatusBarItem: () => { |
| 38 | + return { |
| 39 | + show: vi.fn(), |
| 40 | + iconClass: '', |
| 41 | + }; |
| 42 | + }, |
| 43 | + withProgress: (_options: ProgressOptions, callback: (option: any) => void) => { |
48 | 44 | return callback({ |
49 | 45 | report: () => {}, |
50 | 46 | }); |
51 | 47 | }, |
52 | 48 | showInformationMessage: vi.fn(), |
53 | | - }, |
54 | | - env: { |
55 | | - createTelemetryLogger: vi.fn().mockImplementation(() => ({ |
56 | | - logUsage: vi.fn(), |
57 | | - logError: vi.fn(), |
58 | | - })), |
59 | | - }, |
60 | | - StatusBarAlignLeft: 'LEFT', |
61 | | - ProgressLocation: { |
| 49 | + }; |
| 50 | + |
| 51 | +export const StatusBarAlignLeft = 'LEFT'; |
| 52 | +export const ProgressLocation = { |
62 | 53 | TASK_WIDGET: 2, |
63 | | - }, |
64 | | - process: { |
| 54 | + }; |
| 55 | +export const process = { |
65 | 56 | exec: vi.fn(), |
66 | | - }, |
67 | | - configuration: { |
| 57 | + }; |
| 58 | + |
| 59 | +export const configuration = { |
68 | 60 | getConfiguration: () => { |
69 | 61 | return { |
70 | 62 | get: vi.fn(), |
71 | 63 | }; |
72 | 64 | }, |
73 | | - }, |
74 | | - extensions: { |
| 65 | + }; |
| 66 | + |
| 67 | +export const extensions = { |
75 | 68 | getExtension: vi.fn(), |
76 | | - } |
| 69 | + }; |
| 70 | + |
| 71 | +export const env = { |
| 72 | + createTelemetryLogger: vi.fn().mockImplementation(() => ({ |
| 73 | + logUsage: vi.fn(), |
| 74 | + logError: vi.fn(), |
| 75 | + })), |
| 76 | + }; |
| 77 | + |
| 78 | +export const authentication = { |
| 79 | + registerAuthenticationProvider: vi.fn(), |
| 80 | + getSession: vi.fn(), |
| 81 | + onDidChangeSessions: vi.fn(), |
| 82 | + }; |
| 83 | + |
| 84 | +export class EventEmitter { |
| 85 | + constructor() {}; |
| 86 | + fire = vi.fn(); |
77 | 87 | }; |
78 | 88 |
|
79 | | -module.exports = plugin; |
| 89 | + |
0 commit comments