2024-06-19 03:35:42 -07:00
|
|
|
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,
|
|
|
|
);
|
|
|
|
|
2024-06-20 02:02:30 -07:00
|
|
|
describe('collectPassthroughData', () => {
|
|
|
|
test('should return an object with active workflow IDs', async () => {
|
2024-06-19 03:35:42 -07:00
|
|
|
/**
|
|
|
|
* Arrange
|
|
|
|
*/
|
|
|
|
const activeWorkflowIds = ['1', '2'];
|
|
|
|
workflowRepository.getActiveIds.mockResolvedValue(activeWorkflowIds);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Act
|
|
|
|
*/
|
2024-06-20 02:02:30 -07:00
|
|
|
const result = await usageMetricsService.collectPassthroughData();
|
2024-06-19 03:35:42 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert
|
|
|
|
*/
|
|
|
|
expect(result).toEqual({ activeWorkflowIds });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|