Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { mockInstance } from '@n8n/backend-test-utils';
|
|
import { Container } from '@n8n/di';
|
|
|
|
import { ClearLicenseCommand } from '@/commands/license/clear';
|
|
import { License } from '@/license';
|
|
import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials';
|
|
import { setupTestCommand } from '@test-integration/utils/test-command';
|
|
|
|
mockInstance(LoadNodesAndCredentials);
|
|
const command = setupTestCommand(ClearLicenseCommand);
|
|
|
|
test('license:clear invokes clear() to release any floating entitlements and deletes the license cert from the DB', async () => {
|
|
const license = Container.get(License);
|
|
|
|
const manager = {
|
|
clear: jest.fn().mockImplementation(async () => {
|
|
await license.saveCertStr('');
|
|
}),
|
|
};
|
|
|
|
const initSpy = jest.spyOn(license, 'init').mockImplementation(async () => {
|
|
Object.defineProperty(license, 'manager', {
|
|
value: manager,
|
|
writable: true,
|
|
});
|
|
});
|
|
|
|
const clearSpy = jest.spyOn(license, 'clear');
|
|
const saveCertStrSpy = jest.spyOn(license, 'saveCertStr');
|
|
|
|
await command.run();
|
|
|
|
expect(initSpy).toHaveBeenCalledTimes(1);
|
|
expect(clearSpy).toHaveBeenCalledTimes(1);
|
|
expect(saveCertStrSpy).toHaveBeenCalledWith('');
|
|
});
|