import { describe, test, expect, afterEach } from 'vitest';
import { getClipboardNodeId, setClipboardNodeId } from './clipboard';

describe('clipboard', () => {
  afterEach(() => {
    setClipboardNodeId(null);
  });

  test('starts empty', () => {
    expect(getClipboardNodeId()).toBeNull();
  });

  test('set then get returns the stored node id', () => {
    setClipboardNodeId('node-123');
    expect(getClipboardNodeId()).toBe('node-123');
  });

  test('is a shared module-level store -- overwriting replaces the previous value', () => {
    setClipboardNodeId('first');
    setClipboardNodeId('second');
    expect(getClipboardNodeId()).toBe('second');
  });

  test('can be cleared back to null', () => {
    setClipboardNodeId('node-123');
    setClipboardNodeId(null);
    expect(getClipboardNodeId()).toBeNull();
  });
});
