fix: correct question parsing/building after use of styling. TNL-10413.
This commit is contained in:
@@ -274,7 +274,10 @@ export class OLXParser {
|
||||
}
|
||||
|
||||
parseQuestions(problemType) {
|
||||
const builder = new XMLBuilder();
|
||||
const options = {
|
||||
ignoreAttributes: false,
|
||||
};
|
||||
const builder = new XMLBuilder(options);
|
||||
const problemObject = _.get(this.problem, problemType);
|
||||
let questionObject = {};
|
||||
/* TODO: How do we uniquely identify the label and description?
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
multipleProblemOlX,
|
||||
blankProblemOLX,
|
||||
blankQuestionOLX,
|
||||
styledQuestionOLX,
|
||||
} from './mockData/olxTestData';
|
||||
import { ProblemTypeKeys } from '../../../data/constants/problem';
|
||||
|
||||
@@ -161,6 +162,12 @@ describe('Check OLXParser for question parsing', () => {
|
||||
const question = olxparser.parseQuestions(problemType);
|
||||
expect(question).toBe(blankQuestionOLX.question);
|
||||
});
|
||||
test('Test OLX question content with styling should parse/build with correct styling', () => {
|
||||
const olxparser = new OLXParser(styledQuestionOLX.rawOLX);
|
||||
const problemType = olxparser.getProblemType();
|
||||
const question = olxparser.parseQuestions(problemType);
|
||||
expect(question).toBe(styledQuestionOLX.question);
|
||||
});
|
||||
});
|
||||
|
||||
describe('OLXParser for problem with solution tag', () => {
|
||||
|
||||
@@ -613,3 +613,19 @@ export const blankQuestionOLX = {
|
||||
</problem>`,
|
||||
question: '',
|
||||
};
|
||||
export const styledQuestionOLX = {
|
||||
rawOLX: `<problem>
|
||||
<p>
|
||||
<strong>
|
||||
<span style="background-color: #e03e2d;">
|
||||
test
|
||||
</span>
|
||||
</strong>
|
||||
</p>
|
||||
<stringresponse type="ci">
|
||||
<additional_answer />
|
||||
<textline size="20"/>
|
||||
</stringresponse>
|
||||
</problem>`,
|
||||
question: '<p><strong><span style="background-color: #e03e2d;">test</span></strong></p>',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user