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.

611 B
Raw Blame
import { prioritizeOrAddOptionForMultiSelect } from '../utils';

describe('prioritizeOrAddOptionForMultiSelect ordering', () => {
	it('hoists selected then preserves the given (sorted) order in each group', () => {
		const sorted = ['apple', 'banana', 'cherry', 'date', 'elderberry'].map(
			(v) => ({ label: v, value: v }),
		);
		// selection given in a non-sorted order on purpose
		const result = prioritizeOrAddOptionForMultiSelect(sorted, [
			'date',
			'banana',
		]);
		expect(result.map((o) => o.value)).toStrictEqual([
			'banana',
			'date',
			'apple',
			'cherry',
			'elderberry',
		]);
	});
});