import { describe, it, expect } from 'vitest';
import { resolveTrainingMark, RECOGNITION_TRAINING_LABEL } from './trainingMark';

describe('resolveTrainingMark', () => {
	it('is a no-op (null) when no region is active', () => {
		expect(resolveTrainingMark(null, [])).toBe(null);
		expect(resolveTrainingMark(null, [RECOGNITION_TRAINING_LABEL])).toBe(null);
	});

	it('enrols recognition training when a region is active and not yet enrolled', () => {
		expect(resolveTrainingMark('ann-1', [])).toEqual({
			label: RECOGNITION_TRAINING_LABEL,
			enrolled: true
		});
	});

	it('un-enrols when recognition training is already enrolled', () => {
		expect(resolveTrainingMark('ann-1', [RECOGNITION_TRAINING_LABEL])).toEqual({
			label: RECOGNITION_TRAINING_LABEL,
			enrolled: false
		});
	});

	it('ignores unrelated document training labels', () => {
		expect(resolveTrainingMark('ann-1', ['KURRENT_SEGMENTATION'])).toEqual({
			label: RECOGNITION_TRAINING_LABEL,
			enrolled: true
		});
	});
});
