just testing the environment
Some checks failed
Tests / test (push) Has been cancelled

This commit is contained in:
tom.hempel
2026-05-20 07:10:08 +02:00
parent 2a11dfd0d1
commit 06fc134299
56 changed files with 1890 additions and 361 deletions

View File

@ -0,0 +1,39 @@
import { describe, it, expect, beforeEach } from 'vitest';
import {
parseConfig,
questionLocalIds,
layoutLabel,
readConfigFromForm,
} from '../../js/editor-utils.js';
describe('editor-utils', () => {
beforeEach(() => {
document.body.innerHTML = '';
});
it('parseConfig parses JSON', () => {
expect(parseConfig({ configJson: '{"textKey":"a"}' })).toEqual({ textKey: 'a' });
expect(parseConfig({ configJson: 'not-json' })).toEqual({});
});
it('questionLocalIds extracts short ids', () => {
const ids = questionLocalIds([
{ questionID: 'qn__q1', defaultText: 'Q1' },
{ questionID: 'qn__q2', defaultText: 'Q2' },
]);
expect(ids.map(i => i.localId)).toEqual(['q1', 'q2']);
});
it('layoutLabel resolves known layouts', () => {
expect(layoutLabel('radio_question')).toContain('Radio');
});
it('readConfigFromForm round-trips value_spinner', () => {
document.body.innerHTML = `
<input id="pfx_rangeMin" value="1" />
<input id="pfx_rangeMax" value="10" />
`;
const json = readConfigFromForm('value_spinner', 'pfx');
expect(JSON.parse(json)).toEqual({ range: { min: 1, max: 10 } });
});
});