import { describe, it, expect, beforeEach } from 'vitest';
import { commandRegistry } from '../commands/registry';
import {
	exportCanvasCommand,
	importCanvasCommand,
	registerSerializationCommands,
} from '../commands/builtins/serialization-commands';

describe('serialization-commands', () => {
	beforeEach(() => {
		commandRegistry.clear();
	});

	it('exportCanvasCommand has correct shape', () => {
		expect(exportCanvasCommand.name).toBeTruthy();
		expect(typeof exportCanvasCommand.execute).toBe('function');
	});

	it('importCanvasCommand has correct shape', () => {
		expect(importCanvasCommand.name).toBeTruthy();
		expect(typeof importCanvasCommand.execute).toBe('function');
	});

	it('registerSerializationCommands registers both', () => {
		registerSerializationCommands();
		expect(commandRegistry.has(exportCanvasCommand.name)).toBe(true);
		expect(commandRegistry.has(importCanvasCommand.name)).toBe(true);
	});

	it('both commands have descriptions', () => {
		expect(exportCanvasCommand.description).toBeTruthy();
		expect(importCanvasCommand.description).toBeTruthy();
	});

	it('commands have distinct names', () => {
		expect(exportCanvasCommand.name).not.toBe(importCanvasCommand.name);
	});
});
