import { describe, expect, it } from 'vitest';

import { normalizeStoredDrawingData } from '../utils/drawingData.js';

describe('predefined activity drawing data', () => {
  it('stores drawing objects as JSON once', () => {
    expect(normalizeStoredDrawingData({ selectedStartPosition: 'AS1' }))
      .toBe('{"selectedStartPosition":"AS1"}');
  });

  it('does not double encode JSON text sent by mobile clients', () => {
    expect(normalizeStoredDrawingData('{"strokeType":"VH"}'))
      .toBe('{"strokeType":"VH"}');
  });

  it('repairs previously double encoded JSON text', () => {
    expect(normalizeStoredDrawingData('"{\\"targetPosition\\":\\"5\\"}"'))
      .toBe('{"targetPosition":"5"}');
  });
});
