Implement multiline options support and legacy field handling in Dynamic Poll

This commit is contained in:
Torsten Brendgen
2026-08-24 09:32:31 +02:00
parent ca41674188
commit 53690530bc
6 changed files with 104 additions and 24 deletions
+4 -2
View File
@@ -1,4 +1,4 @@
import { calculatePollResults, findUserAnswer, selectActivePoll } from '../src/webparts/dynamicPoll/PollCore';
import { calculatePollResults, findUserAnswer, parsePollOptionLines, selectActivePoll } from '../src/webparts/dynamicPoll/PollCore';
import { IPoll, IPollAnswer } from '../src/webparts/dynamicPoll/PollTypes';
let passed: number = 0;
@@ -30,5 +30,7 @@ assert('votes are counted per configured option', results[0].votes === 2 && resu
assert('invalid legacy answer is excluded from percentage', results[0].percentage === 67 && results[1].percentage === 33);
assert('user lookup is case insensitive', findUserAnswer(answers, 'ONE@CONTOSO.LOCAL') === 'A');
assert('unknown user has no answer', findUserAnswer(answers, 'unknown@contoso.local') === '');
const parsedOptions: string[] = parsePollOptionLines(['Ja\r\nNein\n\n Anderer Termin ', 'ja']);
assert('multiline options are trimmed, split and deduplicated',
parsedOptions.length === 3 && parsedOptions[0] === 'Ja' && parsedOptions[2] === 'Anderer Termin');
console.log('DynamicPoll core tests passed:', passed);