mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
33 lines
938 B
TypeScript
33 lines
938 B
TypeScript
|
import { mock } from 'jest-mock-extended';
|
||
|
import { UsageMetricsService } from '@/services/usageMetrics.service';
|
||
|
import type { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||
|
import type { UsageMetricsRepository } from '@/databases/repositories/usageMetrics.repository';
|
||
|
|
||
|
describe('UsageMetricsService', () => {
|
||
|
const workflowRepository = mock<WorkflowRepository>();
|
||
|
const usageMetricsService = new UsageMetricsService(
|
||
|
mock<UsageMetricsRepository>(),
|
||
|
workflowRepository,
|
||
|
);
|
||
|
|
||
|
describe('getActiveWorkflowIds', () => {
|
||
|
test('should return active workflow IDs', async () => {
|
||
|
/**
|
||
|
* Arrange
|
||
|
*/
|
||
|
const activeWorkflowIds = ['1', '2'];
|
||
|
workflowRepository.getActiveIds.mockResolvedValue(activeWorkflowIds);
|
||
|
|
||
|
/**
|
||
|
* Act
|
||
|
*/
|
||
|
const result = await usageMetricsService.getActiveWorkflowIds();
|
||
|
|
||
|
/**
|
||
|
* Assert
|
||
|
*/
|
||
|
expect(result).toEqual({ activeWorkflowIds });
|
||
|
});
|
||
|
});
|
||
|
});
|