Implement multiline options support and legacy field handling in Dynamic Poll
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user