Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

948 B
Raw Blame
import { themeColors } from 'constants/theme';
import { Span } from 'types/api/trace/getTraceItem';

import spans from './__fixtures__/getRandomColor';
import { colors, spanServiceNameToColorMapping } from './getRandomColor';

describe('spanServiceNameToColorMapping', () => {
	it('should map span services to colors', () => {
		const expectedServiceToColorMap = {
			serviceA: themeColors.chartcolors.turquoise,
			serviceB: themeColors.chartcolors.turquoise,
			serviceC: colors[2], // 2 is because we have already used 0 and 1 in the above services,
		};

		const result = spanServiceNameToColorMapping(spans);

		expect(result).toStrictEqual(expectedServiceToColorMap);
	});

	it('should return an empty object when input is an empty array', () => {
		const spans: Span[] = [];

		const expectedServiceToColorMap = {};

		const result = spanServiceNameToColorMapping(spans);

		expect(result).toStrictEqual(expectedServiceToColorMap);
	});
});