mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Refactor cli command tests (no-changelog) (#9731)
This commit is contained in:
committed by
GitHub
parent
fb73ec3994
commit
2d02c73fbd
@@ -2,27 +2,18 @@ import { InternalHooks } from '@/InternalHooks';
|
||||
import { License } from '@/License';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
import { ClearLicenseCommand } from '@/commands/license/clear';
|
||||
import { Config } from '@oclif/core';
|
||||
|
||||
import { setupTestCommand } from '@test-integration/utils/testCommand';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
|
||||
const oclifConfig = new Config({ root: __dirname });
|
||||
|
||||
beforeAll(async () => {
|
||||
mockInstance(InternalHooks);
|
||||
mockInstance(LoadNodesAndCredentials);
|
||||
await oclifConfig.load();
|
||||
});
|
||||
mockInstance(InternalHooks);
|
||||
mockInstance(LoadNodesAndCredentials);
|
||||
const license = mockInstance(License);
|
||||
const command = setupTestCommand(ClearLicenseCommand);
|
||||
|
||||
test('license:clear invokes shutdown() to release any floating entitlements', async () => {
|
||||
const cmd = new ClearLicenseCommand([], oclifConfig);
|
||||
await cmd.init();
|
||||
|
||||
const license = mockInstance(License);
|
||||
|
||||
await cmd.run();
|
||||
await command.run();
|
||||
|
||||
expect(license.init).toHaveBeenCalledTimes(1);
|
||||
expect(license.shutdown).toHaveBeenCalledTimes(1);
|
||||
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user