|
| 1 | +import { describe, it, expect, jest } from '@jest/globals'; |
| 2 | +import * as cmd from '../../src/commands/handlers'; |
| 3 | + |
| 4 | +import { window, ExtensionContext } from 'vscode'; |
| 5 | +import * as core from 'lightning-flow-scanner-core'; |
| 6 | +import { CacheProvider } from '../../src/providers/cache-provider'; |
| 7 | +import { OutputChannel } from '../../src/providers/outputChannel'; |
| 8 | + |
| 9 | +jest.mock('lightning-flow-scanner-core'); |
| 10 | +jest.mock('../../src/providers/cache-provider'); |
| 11 | +jest.mock('../../src/providers/outputChannel'); |
| 12 | + |
| 13 | +describe('Commands', () => { |
| 14 | + it('should be defined', () => { |
| 15 | + expect(cmd).toBeDefined(); |
| 16 | + }); |
| 17 | + |
| 18 | + describe('configRules', () => { |
| 19 | + it('should allow selection [legacy]', async () => { |
| 20 | + jest.spyOn(core, 'getBetaRules').mockImplementation(() => [ |
| 21 | + { |
| 22 | + label: 'beta-test', |
| 23 | + name: 'beta-test', |
| 24 | + } as unknown as core.IRuleDefinition, |
| 25 | + ]); |
| 26 | + jest.spyOn(core, 'getRules').mockImplementation(() => [ |
| 27 | + { |
| 28 | + label: 'Flow Name', |
| 29 | + name: 'FlowName', |
| 30 | + } as unknown as core.IRuleDefinition, |
| 31 | + { |
| 32 | + label: 'API Version', |
| 33 | + name: 'APIVersion', |
| 34 | + } as unknown as core.IRuleDefinition, |
| 35 | + ]); |
| 36 | + |
| 37 | + const windowMock = { |
| 38 | + showQuickPick: jest.fn().mockReturnValue([ |
| 39 | + { |
| 40 | + label: 'shit', |
| 41 | + value: 'shit', |
| 42 | + }, |
| 43 | + ]), |
| 44 | + } as any; |
| 45 | + |
| 46 | + const spy = jest.spyOn(window, 'showQuickPick').mockReturnValue([ |
| 47 | + { label: 'Flow Name', value: 'FlowName' }, |
| 48 | + { label: 'API Version', value: 'APIVersion' }, |
| 49 | + ] as any); |
| 50 | + |
| 51 | + const instanceMock = { set: jest.fn() }; |
| 52 | + CacheProvider.instance = instanceMock as any; |
| 53 | + |
| 54 | + const outputMock = { logChannel: { debug: jest.fn() } }; |
| 55 | + const outputSpy = jest.spyOn(OutputChannel, 'getInstance'); //.getInstance = outputMock as any; |
| 56 | + outputSpy.mockReturnValue(outputMock as any); |
| 57 | + |
| 58 | + const extensionContext = jest.fn(); |
| 59 | + const command = new cmd.default( |
| 60 | + extensionContext as unknown as ExtensionContext |
| 61 | + ); |
| 62 | + |
| 63 | + await command['configRules'](); |
| 64 | + }); |
| 65 | + |
| 66 | + it('should read from configuration', async () => {}); |
| 67 | + |
| 68 | + it('should write to configuration', async () => {}); |
| 69 | + }); |
| 70 | +}); |
0 commit comments