@digabi/exam-engine-core 22.1.6-alpha.4 → 22.1.6-move-to-em.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/__tests__/tsconfig.tsbuildinfo +1 -1
- package/dist/components/context/GradingInstructionContext.d.ts +4 -2
- package/dist/components/context/GradingInstructionContext.d.ts.map +1 -1
- package/dist/components/grading-instructions/AnswerGradingInstruction.d.ts.map +1 -1
- package/dist/components/grading-instructions/AnswerGradingInstruction.js +2 -3
- package/dist/components/grading-instructions/AnswerGradingInstruction.js.map +1 -1
- package/dist/components/grading-instructions/GradingInstructionProvider.d.ts +1 -1
- package/dist/components/grading-instructions/GradingInstructionProvider.d.ts.map +1 -1
- package/dist/components/grading-instructions/GradingInstructionProvider.js +4 -2
- package/dist/components/grading-instructions/GradingInstructionProvider.js.map +1 -1
- package/dist/components/grading-instructions/GradingInstructions.js +2 -2
- package/dist/components/grading-instructions/GradingInstructions.js.map +1 -1
- package/dist/main-bundle.js +1 -1
- package/dist/main.css +1 -1
- package/package.json +2 -11
- package/dist/__tests__/EditableGradingInsatruction.test.d.ts +0 -1
- package/dist/__tests__/EditableGradingInsatruction.test.d.ts.map +0 -1
- package/dist/__tests__/EditableGradingInsatruction.test.js +0 -2
- package/dist/__tests__/EditableGradingInsatruction.test.js.map +0 -1
- package/dist/__tests__/EditableGradingInstruction.test.d.ts +0 -2
- package/dist/__tests__/EditableGradingInstruction.test.d.ts.map +0 -1
- package/dist/__tests__/EditableGradingInstruction.test.js +0 -174
- package/dist/__tests__/EditableGradingInstruction.test.js.map +0 -1
- package/dist/__tests__/EditableGradingInstructionLocalization.test.d.ts +0 -2
- package/dist/__tests__/EditableGradingInstructionLocalization.test.d.ts.map +0 -1
- package/dist/__tests__/EditableGradingInstructionLocalization.test.js +0 -75
- package/dist/__tests__/EditableGradingInstructionLocalization.test.js.map +0 -1
- package/dist/__tests__/FormatButton.test.d.ts +0 -2
- package/dist/__tests__/FormatButton.test.d.ts.map +0 -1
- package/dist/__tests__/FormatButton.test.js +0 -94
- package/dist/__tests__/FormatButton.test.js.map +0 -1
- package/dist/__tests__/editor/FormatButton.test.d.ts +0 -2
- package/dist/__tests__/editor/FormatButton.test.d.ts.map +0 -1
- package/dist/__tests__/editor/FormatButton.test.js +0 -98
- package/dist/__tests__/editor/FormatButton.test.js.map +0 -1
- package/dist/__tests__/editor/Formula.test.d.ts +0 -2
- package/dist/__tests__/editor/Formula.test.d.ts.map +0 -1
- package/dist/__tests__/editor/Formula.test.js +0 -61
- package/dist/__tests__/editor/Formula.test.js.map +0 -1
- package/dist/__tests__/editor/ImageUploadButton.test.d.ts +0 -2
- package/dist/__tests__/editor/ImageUploadButton.test.d.ts.map +0 -1
- package/dist/__tests__/editor/ImageUploadButton.test.js +0 -94
- package/dist/__tests__/editor/ImageUploadButton.test.js.map +0 -1
- package/dist/__tests__/editor/List.test.d.ts +0 -2
- package/dist/__tests__/editor/List.test.d.ts.map +0 -1
- package/dist/__tests__/editor/List.test.js +0 -72
- package/dist/__tests__/editor/List.test.js.map +0 -1
- package/dist/__tests__/editor/NBSP.test.d.ts +0 -2
- package/dist/__tests__/editor/NBSP.test.d.ts.map +0 -1
- package/dist/__tests__/editor/NBSP.test.js +0 -55
- package/dist/__tests__/editor/NBSP.test.js.map +0 -1
- package/dist/__tests__/editor/Table.test.d.ts +0 -2
- package/dist/__tests__/editor/Table.test.d.ts.map +0 -1
- package/dist/__tests__/editor/Table.test.js +0 -172
- package/dist/__tests__/editor/Table.test.js.map +0 -1
- package/dist/__tests__/editor/br.test.d.ts +0 -2
- package/dist/__tests__/editor/br.test.d.ts.map +0 -1
- package/dist/__tests__/editor/br.test.js +0 -39
- package/dist/__tests__/editor/br.test.js.map +0 -1
- package/dist/__tests__/editor/hr.test.d.ts +0 -2
- package/dist/__tests__/editor/hr.test.d.ts.map +0 -1
- package/dist/__tests__/editor/hr.test.js +0 -39
- package/dist/__tests__/editor/hr.test.js.map +0 -1
- package/dist/__tests__/editor/no-wrap.test.d.ts +0 -2
- package/dist/__tests__/editor/no-wrap.test.d.ts.map +0 -1
- package/dist/__tests__/editor/no-wrap.test.js +0 -43
- package/dist/__tests__/editor/no-wrap.test.js.map +0 -1
- package/dist/__tests__/editor/noWrap.test.d.ts +0 -2
- package/dist/__tests__/editor/noWrap.test.d.ts.map +0 -1
- package/dist/__tests__/editor/noWrap.test.js +0 -62
- package/dist/__tests__/editor/noWrap.test.js.map +0 -1
- package/dist/__tests__/editor/spanLang.test.d.ts +0 -2
- package/dist/__tests__/editor/spanLang.test.d.ts.map +0 -1
- package/dist/__tests__/editor/spanLang.test.js +0 -50
- package/dist/__tests__/editor/spanLang.test.js.map +0 -1
- package/dist/__tests__/editor/spanWithLang.test.d.ts +0 -2
- package/dist/__tests__/editor/spanWithLang.test.d.ts.map +0 -1
- package/dist/__tests__/editor/spanWithLang.test.js +0 -38
- package/dist/__tests__/editor/spanWithLang.test.js.map +0 -1
- package/dist/__tests__/editor/sub.test.d.ts +0 -2
- package/dist/__tests__/editor/sub.test.d.ts.map +0 -1
- package/dist/__tests__/editor/sub.test.js +0 -62
- package/dist/__tests__/editor/sub.test.js.map +0 -1
- package/dist/__tests__/editor/subSup.test.d.ts +0 -2
- package/dist/__tests__/editor/subSup.test.d.ts.map +0 -1
- package/dist/__tests__/editor/subSup.test.js +0 -50
- package/dist/__tests__/editor/subSup.test.js.map +0 -1
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.d.ts +0 -1
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.d.ts.map +0 -1
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.js +0 -2
- package/dist/__tests__/utils/EditableGradingInstructionsWrapper.js.map +0 -1
- package/dist/__tests__/utils/ProseMirrorWrapper.d.ts +0 -8
- package/dist/__tests__/utils/ProseMirrorWrapper.d.ts.map +0 -1
- package/dist/__tests__/utils/ProseMirrorWrapper.js +0 -44
- package/dist/__tests__/utils/ProseMirrorWrapper.js.map +0 -1
- package/dist/__tests__/utils/prosemirror.d.ts +0 -2
- package/dist/__tests__/utils/prosemirror.d.ts.map +0 -1
- package/dist/__tests__/utils/prosemirror.js +0 -30
- package/dist/__tests__/utils/prosemirror.js.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstruction.d.ts +0 -4
- package/dist/__tests__/utils/renderEditableGradingInstruction.d.ts.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstruction.js +0 -22
- package/dist/__tests__/utils/renderEditableGradingInstruction.js.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstructions.d.ts +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstructions.d.ts.map +0 -1
- package/dist/__tests__/utils/renderEditableGradingInstructions.js +0 -2
- package/dist/__tests__/utils/renderEditableGradingInstructions.js.map +0 -1
- package/dist/__tests__/utils/util.d.ts +0 -2
- package/dist/__tests__/utils/util.d.ts.map +0 -1
- package/dist/__tests__/utils/util.js +0 -10
- package/dist/__tests__/utils/util.js.map +0 -1
- package/dist/components/LexicalEditor.d.ts +0 -3
- package/dist/components/LexicalEditor.d.ts.map +0 -1
- package/dist/components/LexicalEditor.js +0 -44
- package/dist/components/LexicalEditor.js.map +0 -1
- package/dist/components/RTE.d.ts +0 -3
- package/dist/components/RTE.d.ts.map +0 -1
- package/dist/components/RTE.js +0 -23
- package/dist/components/RTE.js.map +0 -1
- package/dist/components/TablePlugin.d.ts +0 -1
- package/dist/components/TablePlugin.d.ts.map +0 -1
- package/dist/components/TablePlugin.js +0 -2
- package/dist/components/TablePlugin.js.map +0 -1
- package/dist/components/ToolBarPlugin.d.ts +0 -10
- package/dist/components/ToolBarPlugin.d.ts.map +0 -1
- package/dist/components/ToolBarPlugin.js +0 -111
- package/dist/components/ToolBarPlugin.js.map +0 -1
- package/dist/components/context/AnnotationContext.d.ts +0 -8
- package/dist/components/context/AnnotationContext.d.ts.map +0 -1
- package/dist/components/context/AnnotationContext.js +0 -3
- package/dist/components/context/AnnotationContext.js.map +0 -1
- package/dist/components/exam/ExamineExam.d.ts +0 -5
- package/dist/components/exam/ExamineExam.d.ts.map +0 -1
- package/dist/components/exam/ExamineExam.js +0 -20
- package/dist/components/exam/ExamineExam.js.map +0 -1
- package/dist/components/exam/FinishExam.d.ts +0 -5
- package/dist/components/exam/FinishExam.d.ts.map +0 -1
- package/dist/components/exam/FinishExam.js +0 -17
- package/dist/components/exam/FinishExam.js.map +0 -1
- package/dist/components/grading/reactAnnotation.d.ts +0 -4
- package/dist/components/grading/reactAnnotation.d.ts.map +0 -1
- package/dist/components/grading/reactAnnotation.js +0 -54
- package/dist/components/grading/reactAnnotation.js.map +0 -1
- package/dist/components/grading-instructions/EditableGradingInstruction.d.ts +0 -6
- package/dist/components/grading-instructions/EditableGradingInstruction.d.ts.map +0 -1
- package/dist/components/grading-instructions/EditableGradingInstruction.js +0 -125
- package/dist/components/grading-instructions/EditableGradingInstruction.js.map +0 -1
- package/dist/components/grading-instructions/SlateTableEditor.d.ts +0 -22
- package/dist/components/grading-instructions/SlateTableEditor.d.ts.map +0 -1
- package/dist/components/grading-instructions/SlateTableEditor.js +0 -44
- package/dist/components/grading-instructions/SlateTableEditor.js.map +0 -1
- package/dist/components/grading-instructions/SlateUtils.d.ts +0 -5
- package/dist/components/grading-instructions/SlateUtils.d.ts.map +0 -1
- package/dist/components/grading-instructions/SlateUtils.js +0 -28
- package/dist/components/grading-instructions/SlateUtils.js.map +0 -1
- package/dist/components/grading-instructions/editor/FormatButton.d.ts +0 -9
- package/dist/components/grading-instructions/editor/FormatButton.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/FormatButton.js +0 -26
- package/dist/components/grading-instructions/editor/FormatButton.js.map +0 -1
- package/dist/components/grading-instructions/editor/Formula.d.ts +0 -15
- package/dist/components/grading-instructions/editor/Formula.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/Formula.js +0 -41
- package/dist/components/grading-instructions/editor/Formula.js.map +0 -1
- package/dist/components/grading-instructions/editor/FormulaPopup.d.ts +0 -7
- package/dist/components/grading-instructions/editor/FormulaPopup.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/FormulaPopup.js +0 -49
- package/dist/components/grading-instructions/editor/FormulaPopup.js.map +0 -1
- package/dist/components/grading-instructions/editor/ImageUploadButton.d.ts +0 -6
- package/dist/components/grading-instructions/editor/ImageUploadButton.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/ImageUploadButton.js +0 -77
- package/dist/components/grading-instructions/editor/ImageUploadButton.js.map +0 -1
- package/dist/components/grading-instructions/editor/List.d.ts +0 -9
- package/dist/components/grading-instructions/editor/List.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/List.js +0 -41
- package/dist/components/grading-instructions/editor/List.js.map +0 -1
- package/dist/components/grading-instructions/editor/MathPopup.d.ts +0 -10
- package/dist/components/grading-instructions/editor/MathPopup.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/MathPopup.js +0 -94
- package/dist/components/grading-instructions/editor/MathPopup.js.map +0 -1
- package/dist/components/grading-instructions/editor/Menu.d.ts +0 -1
- package/dist/components/grading-instructions/editor/Menu.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/Menu.js +0 -2
- package/dist/components/grading-instructions/editor/Menu.js.map +0 -1
- package/dist/components/grading-instructions/editor/NBSP.d.ts +0 -4
- package/dist/components/grading-instructions/editor/NBSP.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/NBSP.js +0 -17
- package/dist/components/grading-instructions/editor/NBSP.js.map +0 -1
- package/dist/components/grading-instructions/editor/Table.d.ts +0 -6
- package/dist/components/grading-instructions/editor/Table.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/Table.js +0 -186
- package/dist/components/grading-instructions/editor/Table.js.map +0 -1
- package/dist/components/grading-instructions/editor/findNode.d.ts +0 -3
- package/dist/components/grading-instructions/editor/findNode.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/findNode.js +0 -10
- package/dist/components/grading-instructions/editor/findNode.js.map +0 -1
- package/dist/components/grading-instructions/editor/keymap.d.ts +0 -2
- package/dist/components/grading-instructions/editor/keymap.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/keymap.js +0 -12
- package/dist/components/grading-instructions/editor/keymap.js.map +0 -1
- package/dist/components/grading-instructions/editor/localization.d.ts +0 -3
- package/dist/components/grading-instructions/editor/localization.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/localization.js +0 -36
- package/dist/components/grading-instructions/editor/localization.js.map +0 -1
- package/dist/components/grading-instructions/editor/math-svg.d.ts +0 -2
- package/dist/components/grading-instructions/editor/math-svg.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/math-svg.js +0 -22
- package/dist/components/grading-instructions/editor/math-svg.js.map +0 -1
- package/dist/components/grading-instructions/editor/math.d.ts +0 -4
- package/dist/components/grading-instructions/editor/math.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/math.js +0 -55
- package/dist/components/grading-instructions/editor/math.js.map +0 -1
- package/dist/components/grading-instructions/editor/noWrap.d.ts +0 -3
- package/dist/components/grading-instructions/editor/noWrap.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/noWrap.js +0 -13
- package/dist/components/grading-instructions/editor/noWrap.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/formulaSchema.d.ts +0 -4
- package/dist/components/grading-instructions/editor/schemas/formulaSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/formulaSchema.js +0 -62
- package/dist/components/grading-instructions/editor/schemas/formulaSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/image-schema.d.ts +0 -4
- package/dist/components/grading-instructions/editor/schemas/image-schema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/image-schema.js +0 -47
- package/dist/components/grading-instructions/editor/schemas/image-schema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/imageSchema.d.ts +0 -4
- package/dist/components/grading-instructions/editor/schemas/imageSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/imageSchema.js +0 -61
- package/dist/components/grading-instructions/editor/schemas/imageSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/listSchema.d.ts +0 -72
- package/dist/components/grading-instructions/editor/schemas/listSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/listSchema.js +0 -7
- package/dist/components/grading-instructions/editor/schemas/listSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/spanLang.d.ts +0 -3
- package/dist/components/grading-instructions/editor/schemas/spanLang.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/spanLang.js +0 -23
- package/dist/components/grading-instructions/editor/schemas/spanLang.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/spanWithLangSchema.d.ts +0 -3
- package/dist/components/grading-instructions/editor/schemas/spanWithLangSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/spanWithLangSchema.js +0 -19
- package/dist/components/grading-instructions/editor/schemas/spanWithLangSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/spanWithNowrapSchema.d.ts +0 -3
- package/dist/components/grading-instructions/editor/schemas/spanWithNowrapSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/spanWithNowrapSchema.js +0 -19
- package/dist/components/grading-instructions/editor/schemas/spanWithNowrapSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/subSup.d.ts +0 -3
- package/dist/components/grading-instructions/editor/schemas/subSup.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/subSup.js +0 -23
- package/dist/components/grading-instructions/editor/schemas/subSup.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/subSupSchema.d.ts +0 -3
- package/dist/components/grading-instructions/editor/schemas/subSupSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/subSupSchema.js +0 -23
- package/dist/components/grading-instructions/editor/schemas/subSupSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/tableSchema.d.ts +0 -3
- package/dist/components/grading-instructions/editor/schemas/tableSchema.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/schemas/tableSchema.js +0 -43
- package/dist/components/grading-instructions/editor/schemas/tableSchema.js.map +0 -1
- package/dist/components/grading-instructions/editor/spanWithClass.d.ts +0 -3
- package/dist/components/grading-instructions/editor/spanWithClass.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/spanWithClass.js +0 -19
- package/dist/components/grading-instructions/editor/spanWithClass.js.map +0 -1
- package/dist/components/grading-instructions/editor/spanWithNowrap.d.ts +0 -3
- package/dist/components/grading-instructions/editor/spanWithNowrap.d.ts.map +0 -1
- package/dist/components/grading-instructions/editor/spanWithNowrap.js +0 -19
- package/dist/components/grading-instructions/editor/spanWithNowrap.js.map +0 -1
- package/dist/components/grading-instructions/prosemirror.d.ts +0 -8
- package/dist/components/grading-instructions/prosemirror.d.ts.map +0 -1
- package/dist/components/grading-instructions/prosemirror.js +0 -108
- package/dist/components/grading-instructions/prosemirror.js.map +0 -1
- package/dist/components/results/isExamFinishPageHook.d.ts +0 -2
- package/dist/components/results/isExamFinishPageHook.d.ts.map +0 -1
- package/dist/components/results/isExamFinishPageHook.js +0 -7
- package/dist/components/results/isExamFinishPageHook.js.map +0 -1
- package/dist/components/shared/CreateAnnotationPopup.d.ts +0 -6
- package/dist/components/shared/CreateAnnotationPopup.d.ts.map +0 -1
- package/dist/components/shared/CreateAnnotationPopup.js +0 -11
- package/dist/components/shared/CreateAnnotationPopup.js.map +0 -1
- package/dist/components/shared/PopupUtils.d.ts +0 -4
- package/dist/components/shared/PopupUtils.d.ts.map +0 -1
- package/dist/components/shared/PopupUtils.js +0 -26
- package/dist/components/shared/PopupUtils.js.map +0 -1
- package/dist/store/listenerMiddleware.d.ts +0 -89
- package/dist/store/listenerMiddleware.d.ts.map +0 -1
- package/dist/store/listenerMiddleware.js +0 -6
- package/dist/store/listenerMiddleware.js.map +0 -1
@@ -1,174 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = require("@testing-library/react");
|
7
|
-
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
8
|
-
const renderEditableGradingInstruction_1 = require("./utils/renderEditableGradingInstruction");
|
9
|
-
const util_1 = require("./utils/util");
|
10
|
-
require("@testing-library/jest-dom");
|
11
|
-
const act = react_1.act;
|
12
|
-
describe('EditableGradingInstruction', () => {
|
13
|
-
let cleanup;
|
14
|
-
let onContentChangeMock;
|
15
|
-
beforeEach(() => {
|
16
|
-
onContentChangeMock = jest.fn();
|
17
|
-
});
|
18
|
-
afterEach(() => {
|
19
|
-
if (cleanup) {
|
20
|
-
cleanup();
|
21
|
-
}
|
22
|
-
cleanup = null;
|
23
|
-
});
|
24
|
-
describe('table', () => {
|
25
|
-
it('Table is rendered as expected', () => {
|
26
|
-
const inputData = '<table class="e-table"><tbody><tr><td>foo</td></tr></tbody></table>';
|
27
|
-
const expectedOutput = '<table class="e-table"><tbody><tr><td>foo</td></tr></tbody></table>';
|
28
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData);
|
29
|
-
const table = result.container.querySelector('.ProseMirror');
|
30
|
-
expect(table.innerHTML).toBe(expectedOutput);
|
31
|
-
});
|
32
|
-
it('Change in table is returned as expected', async () => {
|
33
|
-
cleanup = mockCreateRange();
|
34
|
-
const inputData = '<table class="e-table"><tbody><tr><td>foo</td></tr></tbody></table>';
|
35
|
-
const expectedOutput = '<table class="e-table"><tbody><tr><td>bar</td></tr></tbody></table>';
|
36
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
37
|
-
await act(async () => {
|
38
|
-
(0, util_1.insertText)(await result.findByText('foo'), 'bar');
|
39
|
-
});
|
40
|
-
expect(onContentChangeMock).toHaveBeenCalledTimes(1);
|
41
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
42
|
-
});
|
43
|
-
it('Insert table adds expected table', async () => {
|
44
|
-
const inputData = '';
|
45
|
-
const expectedOutput = '<table class="e-table e-width-half"><tbody><tr><td></td><td></td></tr><tr><td></td><td></td></tr></tbody></table>';
|
46
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
47
|
-
await act(async () => {
|
48
|
-
await user_event_1.default.click(await result.findByTestId('editor-menu-add-table'));
|
49
|
-
});
|
50
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
51
|
-
});
|
52
|
-
it('Remove table removes table', async () => {
|
53
|
-
const inputData = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
54
|
-
const expectedOutput = '<p></p>';
|
55
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
56
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Poista taulukko');
|
57
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
58
|
-
});
|
59
|
-
it('Insert column adds column', async () => {
|
60
|
-
const inputData = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
61
|
-
const expectedOutput = '<table><tbody><tr><td>foo</td><td></td></tr></tbody></table>';
|
62
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
63
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Lisää sarake');
|
64
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
65
|
-
});
|
66
|
-
it('Remove column removes column', async () => {
|
67
|
-
const inputData = '<table><tbody><tr><td>foo</td><td>bar</td></tr></tbody></table>';
|
68
|
-
const expectedOutput = '<table><tbody><tr><td>bar</td></tr></tbody></table>';
|
69
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
70
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Poista sarake');
|
71
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
72
|
-
});
|
73
|
-
it('Insert row adds row', async () => {
|
74
|
-
const inputData = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
75
|
-
const expectedOutput = '<table><tbody><tr><td>foo</td></tr><tr><td></td></tr></tbody></table>';
|
76
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
77
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Lisää rivi');
|
78
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
79
|
-
});
|
80
|
-
it('Remove row removes row', async () => {
|
81
|
-
const inputData = '<table><tbody><tr><td>foo</td></tr><tr><td>bar</td></tr></tbody></table>';
|
82
|
-
const expectedOutput = '<table><tbody><tr><td>bar</td></tr></tbody></table>';
|
83
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
84
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Poista rivi');
|
85
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
86
|
-
});
|
87
|
-
it('Full width changes full width class to table', async () => {
|
88
|
-
const inputData = '<table class="e-width-half"><tbody><tr><td>foo</td></tr></tbody></table>';
|
89
|
-
const expectedOutput = '<table class="e-width-full"><tbody><tr><td>foo</td></tr></tbody></table>';
|
90
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
91
|
-
expect(result.queryByText('Puolikas leveys')).not.toBeInTheDocument();
|
92
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Täysi leveys');
|
93
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
94
|
-
});
|
95
|
-
it('Half width changes half width class to table', async () => {
|
96
|
-
const inputData = '<table class="e-width-full"><tbody><tr><td>foo</td></tr></tbody></table>';
|
97
|
-
const expectedOutput = '<table class="e-width-half"><tbody><tr><td>foo</td></tr></tbody></table>';
|
98
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
99
|
-
expect(result.queryByText('Täysi leveys')).not.toBeInTheDocument();
|
100
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Puolikas leveys');
|
101
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
102
|
-
});
|
103
|
-
it('Remove borders adds e-table--borderless class to table', async () => {
|
104
|
-
const inputData = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
105
|
-
const expectedOutput = '<table class="e-table--borderless"><tbody><tr><td>foo</td></tr></tbody></table>';
|
106
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
107
|
-
expect(result.queryByText('Lisää reunat')).not.toBeInTheDocument();
|
108
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Poista reunat');
|
109
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
110
|
-
});
|
111
|
-
it('Add borders removes e-table--borderless class from table', async () => {
|
112
|
-
const inputData = '<table class="e-table--borderless"><tbody><tr><td>foo</td></tr></tbody></table>';
|
113
|
-
const expectedOutput = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
114
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
115
|
-
expect(result.queryByText('Poista reunat')).not.toBeInTheDocument();
|
116
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Lisää reunat');
|
117
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
118
|
-
});
|
119
|
-
it('Remove zebra removes class from table', async () => {
|
120
|
-
const inputData = '<table class="e-table--zebra"><tbody><tr><td>foo</td></tr></tbody></table>';
|
121
|
-
const expectedOutput = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
122
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
123
|
-
expect(result.queryByText('Lisää raidat')).not.toBeInTheDocument();
|
124
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Poista raidat');
|
125
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
126
|
-
});
|
127
|
-
it('Add zebra adds e-table--zebra class to table', async () => {
|
128
|
-
const inputData = '<table><tbody><tr><td>foo</td></tr></tbody></table>';
|
129
|
-
const expectedOutput = '<table class="e-table--zebra"><tbody><tr><td>foo</td></tr></tbody></table>';
|
130
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
131
|
-
expect(result.queryByText('Poista raidat')).not.toBeInTheDocument();
|
132
|
-
await clickTableMenuButtonWithFocusOnCell(result, 'foo', 'Lisää raidat');
|
133
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
134
|
-
});
|
135
|
-
});
|
136
|
-
});
|
137
|
-
async function clickTableMenuButtonWithFocusOnCell(result, cellText, buttonText) {
|
138
|
-
await act(async () => {
|
139
|
-
await focusOnTablesCell(result, cellText);
|
140
|
-
await user_event_1.default.click(await result.findByText(buttonText));
|
141
|
-
});
|
142
|
-
}
|
143
|
-
async function focusOnTablesCell(result, text) {
|
144
|
-
// Replace cell's text with same text
|
145
|
-
// Hack to get focus on cell without need to mock createRange
|
146
|
-
(0, util_1.insertText)(await result.findByText(text), text);
|
147
|
-
}
|
148
|
-
function mockCreateRange() {
|
149
|
-
const originalCreateRange = global.window.document.createRange;
|
150
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
151
|
-
// @ts-expect-error
|
152
|
-
global.Range = function Range() { };
|
153
|
-
const createContextualFragment = (html) => {
|
154
|
-
const div = document.createElement('div');
|
155
|
-
div.innerHTML = html;
|
156
|
-
return div.children[0];
|
157
|
-
};
|
158
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
159
|
-
// @ts-expect-error
|
160
|
-
Range.prototype.createContextualFragment = (html) => createContextualFragment(html);
|
161
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
162
|
-
// @ts-expect-error
|
163
|
-
global.window.document.createRange = function createRange() {
|
164
|
-
return {
|
165
|
-
setEnd: () => { },
|
166
|
-
setStart: () => { },
|
167
|
-
getBoundingClientRect: () => ({ right: 0 }),
|
168
|
-
getClientRects: () => [],
|
169
|
-
createContextualFragment
|
170
|
-
};
|
171
|
-
};
|
172
|
-
return () => (global.window.document.createRange = originalCreateRange);
|
173
|
-
}
|
174
|
-
//# sourceMappingURL=EditableGradingInstruction.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"EditableGradingInstruction.test.js","sourceRoot":"","sources":["../../__tests__/EditableGradingInstruction.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAqE;AACrE,6EAAmD;AACnD,+FAAmF;AACnF,uCAAyC;AACzC,qCAAkC;AAElC,MAAM,GAAG,GAAG,WAAuD,CAAA;AAEnE,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,IAAI,OAA4B,CAAA;IAChC,IAAI,mBAA8B,CAAA;IAElC,UAAU,CAAC,GAAG,EAAE;QACd,mBAAmB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IACjC,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,CAAA;QACX,CAAC;QACD,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;QACrB,EAAE,CAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,MAAM,SAAS,GAAG,qEAAqE,CAAA;YACvF,MAAM,cAAc,GAAG,qEAAqE,CAAA;YAC5F,MAAM,MAAM,GAAG,IAAA,2DAAwB,EAAC,SAAS,CAAC,CAAA;YAClD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,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B,wBAAwB;SACzB,CAAA;IACH,CAAC,CAAA;IACD,OAAO,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,GAAG,mBAAmB,CAAC,CAAA;AACzE,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"EditableGradingInstructionLocalization.test.d.ts","sourceRoot":"","sources":["../../__tests__/EditableGradingInstructionLocalization.test.tsx"],"names":[],"mappings":""}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const react_1 = require("@testing-library/react");
|
4
|
-
const renderEditableGradingInstruction_1 = require("./utils/renderEditableGradingInstruction");
|
5
|
-
const util_1 = require("./utils/util");
|
6
|
-
const prosemirror_1 = require("./utils/prosemirror");
|
7
|
-
const act = react_1.act;
|
8
|
-
describe('EditableGradingInstructionLocalization', () => {
|
9
|
-
let cleanup;
|
10
|
-
let onContentChangeMock;
|
11
|
-
beforeEach(() => {
|
12
|
-
onContentChangeMock = jest.fn();
|
13
|
-
cleanup = (0, prosemirror_1.mockCreateRange)();
|
14
|
-
});
|
15
|
-
afterEach(() => {
|
16
|
-
if (cleanup) {
|
17
|
-
cleanup();
|
18
|
-
}
|
19
|
-
cleanup = null;
|
20
|
-
});
|
21
|
-
it('preserves localization tags with e-localization attribute on save', async () => {
|
22
|
-
// e-localization attribute is added on mastering exam
|
23
|
-
const inputData = '<p><e:localization lang="sv-FI" exam-type="hearing-impaired" e-localization="1">placeholder</e:localization></p>';
|
24
|
-
const expectedOutput = '<p><e:localization lang="sv-FI" exam-type="hearing-impaired">lokalisaatio</e:localization></p>';
|
25
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
26
|
-
await act(async () => {
|
27
|
-
(0, util_1.insertText)(await result.findByText('placeholder'), 'lokalisaatio');
|
28
|
-
});
|
29
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
30
|
-
});
|
31
|
-
it('localization tags without e-localization attribute are ignored', async () => {
|
32
|
-
const inputData = '<p><e:localization lang="sv-FI" exam-type="hearing-impaired">placeholder</e:localization></p>';
|
33
|
-
const expectedOutput = '<p>lokalisaatio</p>';
|
34
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
35
|
-
await act(async () => {
|
36
|
-
(0, util_1.insertText)(await result.findByText('placeholder'), 'lokalisaatio');
|
37
|
-
});
|
38
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
39
|
-
});
|
40
|
-
it("removes localization's e-localization and hidden attributes on save", async () => {
|
41
|
-
const inputData = '<p>Tämä <e:localization exam-type="visually-impaired" e-localization="1" hidden="hidden">on</e:localization> piilossa</p>';
|
42
|
-
const expectedOutput = '<p>Tämä <e:localization exam-type="visually-impaired">ei ole</e:localization> piilossa</p>';
|
43
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
44
|
-
await act(async () => {
|
45
|
-
(0, util_1.insertText)(await result.findByText('on'), 'ei ole');
|
46
|
-
});
|
47
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
48
|
-
});
|
49
|
-
it('saves all grading instructions as a whole regardless which localization is edited', async () => {
|
50
|
-
const inputData = `
|
51
|
-
<p>Not localized</p>
|
52
|
-
<p>
|
53
|
-
<e:localization e-localization="1">Localized without attributes</e:localization>
|
54
|
-
<e:localization e-localization="1" lang="fi-FI">Localized with language</e:localization>
|
55
|
-
<e:localization e-localization="1" exam-type="visually-impaired">Localized with exam-type</e:localization>
|
56
|
-
<e:localization e-localization="1" lang="sv-FI" exam-type="visually-impaired">Localized with language and exam-type</e:localization>
|
57
|
-
</p>
|
58
|
-
`.replace(/\n/g, '');
|
59
|
-
const expectedOutput = `
|
60
|
-
<p>Not localized</p>
|
61
|
-
<p>
|
62
|
-
<e:localization>Localized without attributes</e:localization>
|
63
|
-
<e:localization lang="fi-FI">Localized with language</e:localization>
|
64
|
-
<e:localization exam-type="visually-impaired">Localized with examType</e:localization>
|
65
|
-
<e:localization lang="sv-FI" exam-type="visually-impaired">Localized with language and exam-type</e:localization>
|
66
|
-
</p>
|
67
|
-
`.replace(/\n/g, '');
|
68
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
69
|
-
await act(async () => {
|
70
|
-
(0, util_1.insertText)(await result.findByText('Localized with exam-type'), 'Localized with examType');
|
71
|
-
});
|
72
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
73
|
-
});
|
74
|
-
});
|
75
|
-
//# sourceMappingURL=EditableGradingInstructionLocalization.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"EditableGradingInstructionLocalization.test.js","sourceRoot":"","sources":["../../__tests__/EditableGradingInstructionLocalization.test.tsx"],"names":[],"mappings":";;AAAA,kDAAuD;AACvD,+FAAmF;AACnF,uCAAyC;AACzC,qDAAqD;AAErD,MAAM,GAAG,GAAG,WAAuD,CAAA;AAEnE,QAAQ,CAAC,wCAAwC,EAAE,GAAG,EAAE;IACtD,IAAI,OAA4B,CAAA;IAChC,IAAI,mBAA8B,CAAA;IAElC,UAAU,CAAC,GAAG,EAAE;QACd,mBAAmB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;QAC/B,OAAO,GAAG,IAAA,6BAAe,GAAE,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,CAAA;QACX,CAAC;QACD,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;QACjF,sDAAsD;QACtD,MAAM,SAAS,GACb,kHAAkH,CAAA;QACpH,MAAM,cAAc,GAClB,gGAAgG,CA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Ac,EAAE,EAAE,CAAC,CAAA;IACtE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mFAAmF,EAAE,KAAK,IAAI,EAAE;QACjG,MAAM,SAAS,GAAG;;;;;;;;CAQrB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAChB,MAAM,cAAc,GAAG;;;;;;;;CAQ1B,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAChB,MAAM,MAAM,GAAG,IAAA,2DAAwB,EAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;QACvE,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE;YACnB,IAAA,iBAAU,EAAC,MAAM,MAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,yBAAyB,CAAC,CAAA;QAC5F,CAAC,CAAC,CAAA;QACF,MAAM,CAAC,mBAAmB,CAAC,CAAC,oBAAoB,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;IACtE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"FormatButton.test.d.ts","sourceRoot":"","sources":["../../__tests__/FormatButton.test.tsx"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAA"}
|
@@ -1,94 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
require("@testing-library/jest-dom");
|
8
|
-
const react_2 = require("@testing-library/react");
|
9
|
-
const ProseMirrorWrapper_1 = __importDefault(require("./utils/ProseMirrorWrapper"));
|
10
|
-
const prosemirror_1 = require("./utils/prosemirror");
|
11
|
-
const FormatButton_1 = __importDefault(require("../src/components/grading-instructions/editor/FormatButton"));
|
12
|
-
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
13
|
-
const act = react_2.act;
|
14
|
-
describe('FormatButton', () => {
|
15
|
-
beforeAll(() => {
|
16
|
-
(0, prosemirror_1.mockCreateRange)();
|
17
|
-
});
|
18
|
-
afterEach(() => {
|
19
|
-
(0, react_2.cleanup)();
|
20
|
-
});
|
21
|
-
describe('Italics', () => {
|
22
|
-
it('Renders italics button', () => {
|
23
|
-
const props = { markName: 'em', displayName: 'Italic' };
|
24
|
-
const { button } = renderEditorWithFormatButton(props);
|
25
|
-
expect(button).toHaveTextContent(props.displayName);
|
26
|
-
});
|
27
|
-
it('Toggles button active state when clicked', async () => {
|
28
|
-
const props = { markName: 'em', displayName: 'Italic' };
|
29
|
-
const { button } = renderEditorWithFormatButton(props);
|
30
|
-
expect(button).toHaveStyle('font-weight: normal');
|
31
|
-
await user_event_1.default.click(button);
|
32
|
-
expect(button).toHaveStyle('font-weight: bold');
|
33
|
-
await user_event_1.default.click(button);
|
34
|
-
expect(button).toHaveStyle('font-weight: normal');
|
35
|
-
});
|
36
|
-
it('formats text', async () => {
|
37
|
-
const props = { markName: 'em', displayName: 'Italic' };
|
38
|
-
const { button, paragraph } = renderEditorWithFormatButton(props);
|
39
|
-
await user_event_1.default.click(button);
|
40
|
-
await act(async () => await (0, prosemirror_1.promisifiedFireEventInput)(paragraph, { target: { innerHTML: 'hello' } }));
|
41
|
-
expect((0, react_2.within)(paragraph).getByRole('emphasis')).toHaveTextContent('hello');
|
42
|
-
});
|
43
|
-
it('em tags are rendered as italic', () => {
|
44
|
-
const props = { markName: 'em', displayName: 'Italic', innerHtml: '<em>Italic text</em>' };
|
45
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
46
|
-
expect((0, react_2.within)(paragraph).getByRole('emphasis')).toHaveTextContent('Italic text');
|
47
|
-
});
|
48
|
-
it('i tags are rendered as italic', () => {
|
49
|
-
const props = { markName: 'em', displayName: 'Italic', innerHtml: '<i>Italic text</i>' };
|
50
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
51
|
-
expect((0, react_2.within)(paragraph).getByRole('emphasis')).toHaveTextContent('Italic text');
|
52
|
-
});
|
53
|
-
});
|
54
|
-
describe('Bold', () => {
|
55
|
-
it('Renders bold button', () => {
|
56
|
-
const props = { markName: 'strong', displayName: 'Bold' };
|
57
|
-
const { button } = renderEditorWithFormatButton(props);
|
58
|
-
expect(button).toHaveTextContent(props.displayName);
|
59
|
-
});
|
60
|
-
it('Toggles button active state when clicked', async () => {
|
61
|
-
const props = { markName: 'strong', displayName: 'Bold' };
|
62
|
-
const { button } = renderEditorWithFormatButton(props);
|
63
|
-
expect(button).toHaveStyle('font-weight: normal');
|
64
|
-
await user_event_1.default.click(button);
|
65
|
-
expect(button).toHaveStyle('font-weight: bold');
|
66
|
-
await user_event_1.default.click(button);
|
67
|
-
expect(button).toHaveStyle('font-weight: normal');
|
68
|
-
});
|
69
|
-
it('formats text', async () => {
|
70
|
-
const props = { markName: 'strong', displayName: 'Bold' };
|
71
|
-
const { button, paragraph } = renderEditorWithFormatButton(props);
|
72
|
-
await user_event_1.default.click(button);
|
73
|
-
await act(async () => await (0, prosemirror_1.promisifiedFireEventInput)(paragraph, { target: { innerHTML: 'hello' } }));
|
74
|
-
expect((0, react_2.within)(paragraph).getByRole('strong')).toHaveTextContent('hello');
|
75
|
-
});
|
76
|
-
it('b tags are rendered as bold', () => {
|
77
|
-
const props = { markName: 'strong', displayName: 'bold', innerHtml: '<b>Bold text</b>' };
|
78
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
79
|
-
expect((0, react_2.within)(paragraph).getByRole('strong')).toHaveTextContent('Bold text');
|
80
|
-
});
|
81
|
-
it('strong tags are rendered as bold', () => {
|
82
|
-
const props = { markName: 'strong', displayName: 'bold', innerHtml: '<strong>Bold text</strong>' };
|
83
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
84
|
-
expect((0, react_2.within)(paragraph).getByRole('strong')).toHaveTextContent('Bold text');
|
85
|
-
});
|
86
|
-
});
|
87
|
-
function renderEditorWithFormatButton(props) {
|
88
|
-
const { markName, displayName, innerHtml = '' } = props;
|
89
|
-
const { getByRole } = (0, react_2.render)(react_1.default.createElement(ProseMirrorWrapper_1.default, { innerHtml: innerHtml },
|
90
|
-
react_1.default.createElement(FormatButton_1.default, { markName: markName, displayName: displayName })));
|
91
|
-
return { button: getByRole('button'), paragraph: getByRole('paragraph') };
|
92
|
-
}
|
93
|
-
});
|
94
|
-
//# sourceMappingURL=FormatButton.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"FormatButton.test.js","sourceRoot":"","sources":["../../__tests__/FormatButton.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,qCAAkC;AAClC,kDAAgF;AAChF,oFAA2D;AAC3D,qDAAgF;AAChF,8GAAqF;AACrF,6EAAmD;AAEnD,MAAM,GAAG,GAAG,WAAuD,CAAA;AAEnE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,IAAA,6BAAe,GAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAA,eAAO,GAAE,CAAA;IACX,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACvB,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;YAChC,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAA;YACvD,MAAM,EAAE,MAAM,EAAE,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAA;YACtD,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;YACxD,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,E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YAC1C,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,4BAA4B,EAAE,CAAA;YAClG,MAAM,EAAE,SAAS,EAAE,GAAG,4BAA4B,CAAC,KAAK,CAAC,CAAA;YACzD,MAAM,CAAC,IAAA,cAAM,EAAC,SAAS,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAA;QAC9E,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,SAAS,4BAA4B,CAAC,KAAoE;QACxG,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,KAAK,CAAA;QACvD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,cAAM,EAC1B,8BAAC,4BAAkB,IAAC,SAAS,EAAE,SAAS;YACtC,8BAAC,sBAAY,IAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAI,CAC3C,CACtB,CAAA;QACD,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,WAAW,CAAC,EAAE,CAAA;IAC3E,CAAC;AACH,CAAC,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"FormatButton.test.d.ts","sourceRoot":"","sources":["../../../__tests__/editor/FormatButton.test.tsx"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAA"}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const react_1 = __importDefault(require("react"));
|
7
|
-
require("@testing-library/jest-dom");
|
8
|
-
const react_2 = require("@testing-library/react");
|
9
|
-
const ProseMirrorWrapper_1 = __importDefault(require("../utils/ProseMirrorWrapper"));
|
10
|
-
const prosemirror_1 = require("../utils/prosemirror");
|
11
|
-
const FormatButton_1 = __importDefault(require("../../src/components/grading-instructions/editor/FormatButton"));
|
12
|
-
const user_event_1 = __importDefault(require("@testing-library/user-event"));
|
13
|
-
const util_1 = require("../utils/util");
|
14
|
-
const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
|
15
|
-
const act = react_2.act;
|
16
|
-
describe('FormatButton', () => {
|
17
|
-
beforeAll(() => {
|
18
|
-
(0, prosemirror_1.mockCreateRange)();
|
19
|
-
});
|
20
|
-
afterEach(() => {
|
21
|
-
(0, react_2.cleanup)();
|
22
|
-
});
|
23
|
-
describe('Italics', () => {
|
24
|
-
it('Renders italics button', () => {
|
25
|
-
const props = { markName: 'em', icon: free_solid_svg_icons_1.faItalic };
|
26
|
-
const { button } = renderEditorWithFormatButton(props);
|
27
|
-
expect(button.children[0]).toHaveAttribute('data-icon', 'italic');
|
28
|
-
});
|
29
|
-
it('Toggles button active state when clicked', async () => {
|
30
|
-
const props = { markName: 'em', icon: free_solid_svg_icons_1.faItalic };
|
31
|
-
const { button } = renderEditorWithFormatButton(props);
|
32
|
-
expect(button).not.toHaveClass('active');
|
33
|
-
await user_event_1.default.click(button);
|
34
|
-
expect(button).toHaveClass('active');
|
35
|
-
await user_event_1.default.click(button);
|
36
|
-
expect(button).not.toHaveClass('active');
|
37
|
-
});
|
38
|
-
it('formats text', async () => {
|
39
|
-
const props = { markName: 'em', icon: free_solid_svg_icons_1.faItalic };
|
40
|
-
const { button, paragraph, container } = renderEditorWithFormatButton(props);
|
41
|
-
await user_event_1.default.click(button);
|
42
|
-
await act(async () => (0, util_1.insertText)(await container.findByRole('paragraph'), 'hello'));
|
43
|
-
expect((0, react_2.within)(paragraph).getByRole('emphasis')).toHaveTextContent('hello');
|
44
|
-
});
|
45
|
-
it('em tags are rendered as italic', () => {
|
46
|
-
const props = { markName: 'em', icon: free_solid_svg_icons_1.faItalic, innerHtml: '<em>Italic text</em>' };
|
47
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
48
|
-
expect((0, react_2.within)(paragraph).getByRole('emphasis')).toHaveTextContent('Italic text');
|
49
|
-
});
|
50
|
-
it('i tags are rendered as italic', () => {
|
51
|
-
const props = { markName: 'em', icon: free_solid_svg_icons_1.faItalic, innerHtml: '<i>Italic text</i>' };
|
52
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
53
|
-
expect((0, react_2.within)(paragraph).getByRole('emphasis')).toHaveTextContent('Italic text');
|
54
|
-
});
|
55
|
-
});
|
56
|
-
describe('Bold', () => {
|
57
|
-
it('Renders bold button', () => {
|
58
|
-
const props = { markName: 'strong', icon: free_solid_svg_icons_1.faBold };
|
59
|
-
const { button } = renderEditorWithFormatButton(props);
|
60
|
-
expect(button.children[0]).toHaveAttribute('data-icon', 'bold');
|
61
|
-
});
|
62
|
-
it('Toggles button active state when clicked', async () => {
|
63
|
-
const props = { markName: 'strong', icon: free_solid_svg_icons_1.faBold };
|
64
|
-
const { button } = renderEditorWithFormatButton(props);
|
65
|
-
expect(button).not.toHaveClass('active');
|
66
|
-
await user_event_1.default.click(button);
|
67
|
-
expect(button).toHaveClass('active');
|
68
|
-
await user_event_1.default.click(button);
|
69
|
-
expect(button).not.toHaveClass('active');
|
70
|
-
});
|
71
|
-
it('formats text', async () => {
|
72
|
-
const props = { markName: 'strong', icon: free_solid_svg_icons_1.faBold };
|
73
|
-
const { button, container, paragraph } = renderEditorWithFormatButton(props);
|
74
|
-
await user_event_1.default.click(button);
|
75
|
-
await act(async () => {
|
76
|
-
(0, util_1.insertText)(await container.findByRole('paragraph'), 'hello');
|
77
|
-
});
|
78
|
-
expect((0, react_2.within)(paragraph).getByRole('strong')).toHaveTextContent('hello');
|
79
|
-
});
|
80
|
-
it('b tags are rendered as bold', () => {
|
81
|
-
const props = { markName: 'strong', icon: free_solid_svg_icons_1.faBold, innerHtml: '<b>Bold text</b>' };
|
82
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
83
|
-
expect((0, react_2.within)(paragraph).getByRole('strong')).toHaveTextContent('Bold text');
|
84
|
-
});
|
85
|
-
it('strong tags are rendered as bold', () => {
|
86
|
-
const props = { markName: 'strong', icon: free_solid_svg_icons_1.faBold, innerHtml: '<strong>Bold text</strong>' };
|
87
|
-
const { paragraph } = renderEditorWithFormatButton(props);
|
88
|
-
expect((0, react_2.within)(paragraph).getByRole('strong')).toHaveTextContent('Bold text');
|
89
|
-
});
|
90
|
-
});
|
91
|
-
function renderEditorWithFormatButton(props) {
|
92
|
-
const { markName, icon, innerHtml = '' } = props;
|
93
|
-
const container = (0, react_2.render)(react_1.default.createElement(ProseMirrorWrapper_1.default, { innerHtml: innerHtml },
|
94
|
-
react_1.default.createElement(FormatButton_1.default, { markName: markName, icon: icon })));
|
95
|
-
return { button: container.getByRole('button'), paragraph: container.getByRole('paragraph'), container };
|
96
|
-
}
|
97
|
-
});
|
98
|
-
//# sourceMappingURL=FormatButton.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"FormatButton.test.js","sourceRoot":"","sources":["../../../__tests__/editor/FormatButton.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,qCAAkC;AAClC,kDAAgF;AAChF,qFAA4D;AAC5D,sDAAsD;AACtD,iHAAwF;AACxF,6EAAmD;AACnD,wCAA0C;AAE1C,4EAAoE;AAEpE,MAAM,GAAG,GAAG,WAAuD,CAAA;AAEnE,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,IAAA,6BAAe,GAAE,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAA,eAAO,GAAE,CAAA;IACX,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;QACvB,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;Y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AAC,SAAS,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAA;IAC1G,CAAC;AACH,CAAC,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Formula.test.d.ts","sourceRoot":"","sources":["../../../__tests__/editor/Formula.test.tsx"],"names":[],"mappings":""}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const react_1 = require("@testing-library/react");
|
4
|
-
const prosemirror_1 = require("../utils/prosemirror");
|
5
|
-
const renderEditableGradingInstruction_1 = require("../utils/renderEditableGradingInstruction");
|
6
|
-
const util_1 = require("../utils/util");
|
7
|
-
const act = react_1.act;
|
8
|
-
describe('Editor - Formula', () => {
|
9
|
-
let cleanup;
|
10
|
-
let onContentChangeMock;
|
11
|
-
beforeEach(() => {
|
12
|
-
onContentChangeMock = jest.fn();
|
13
|
-
});
|
14
|
-
afterEach(() => {
|
15
|
-
if (cleanup) {
|
16
|
-
cleanup();
|
17
|
-
}
|
18
|
-
cleanup = null;
|
19
|
-
});
|
20
|
-
it('Formula is rendered as expected', () => {
|
21
|
-
const inputData = '<p>bar <e:formula data-editor-id="e-formula">foo</e:formula></p>';
|
22
|
-
const expectedOutput = '<p>bar <img alt="foo" formula="true" src="/math.svg?latex=foo"><img class="ProseMirror-separator" alt=""><br class="ProseMirror-trailingBreak"></p>';
|
23
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData);
|
24
|
-
const table = result.container.querySelector('.ProseMirror');
|
25
|
-
expect(table.innerHTML).toBe(expectedOutput);
|
26
|
-
});
|
27
|
-
it('Change in content causes formula to be returned as expected', async () => {
|
28
|
-
cleanup = (0, prosemirror_1.mockCreateRange)();
|
29
|
-
const inputData = '<p>bar</p><p><e:formula data-editor-id="e-formula" mode="inline">foo</e:formula><e:formula data-editor-id="e-formula" assistive-title="foobar">bar</e:formula></p>';
|
30
|
-
const expectedOutput = '<p>foo</p><p><e:formula mode="inline">foo</e:formula><e:formula assistive-title="foobar">bar</e:formula></p>';
|
31
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
32
|
-
await act(async () => {
|
33
|
-
(0, util_1.insertText)(await result.findByText('bar'), 'foo');
|
34
|
-
});
|
35
|
-
expect(onContentChangeMock).toHaveBeenCalledTimes(1);
|
36
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
37
|
-
});
|
38
|
-
it('assistive-tile supports < and > characters correctly', async () => {
|
39
|
-
cleanup = (0, prosemirror_1.mockCreateRange)();
|
40
|
-
const inputData = '<p>bar</p><p><e:formula data-editor-id="e-formula" assistive-title="foobar > 0 < x">bar</e:formula></p>';
|
41
|
-
const expectedOutput = '<p>foo</p><p><e:formula assistive-title="foobar > 0 < x">bar</e:formula></p>';
|
42
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
43
|
-
await act(async () => {
|
44
|
-
(0, util_1.insertText)(await result.findByText('bar'), 'foo');
|
45
|
-
});
|
46
|
-
expect(onContentChangeMock).toHaveBeenCalledTimes(1);
|
47
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
48
|
-
});
|
49
|
-
it('Empty formula is removed when sending changed content', async () => {
|
50
|
-
cleanup = (0, prosemirror_1.mockCreateRange)();
|
51
|
-
const inputData = '<p>bar</p><p><e:formula data-editor-id="e-formula"></e:formula></p>';
|
52
|
-
const expectedOutput = '<p>foo</p><p></p>';
|
53
|
-
const result = (0, renderEditableGradingInstruction_1.renderGradingInstruction)(inputData, onContentChangeMock);
|
54
|
-
await act(async () => {
|
55
|
-
(0, util_1.insertText)(await result.findByText('bar'), 'foo');
|
56
|
-
});
|
57
|
-
expect(onContentChangeMock).toHaveBeenCalledTimes(1);
|
58
|
-
expect(onContentChangeMock).toHaveBeenCalledWith(expectedOutput, '');
|
59
|
-
});
|
60
|
-
});
|
61
|
-
//# sourceMappingURL=Formula.test.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Formula.test.js","sourceRoot":"","sources":["../../../__tests__/editor/Formula.test.tsx"],"names":[],"mappings":";;AAAA,kDAAuD;AACvD,sDAAsD;AACtD,gGAAoF;AACpF,wCAA0C;AAE1C,MAAM,GAAG,GAAG,WAAuD,CAAA;AAEnE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,OAA4B,CAAA;IAChC,IAAI,mBAA8B,CAAA;IAElC,UAAU,CAAC,GAAG,EAAE;QACd,mBAAmB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IACjC,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,EAAE,CAAA;QACX,CAAC;QACD,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,SAAS,GAAG,kEAAkE,CAAA;QACpF,MAAM,cAAc,GAClB,qJAAqJ,CAAA;QACvJ,MAAM,MAAM,GAAG,IAAA,2DAAwB,EAAC,SAAS,CAAC,CAAA;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;QAC5D,MAAM,CAAC,KAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,OAAO,GAAG,IAAA,6BAAe,GAAE,CAAA;QAC3B,MAAM,SAAS,GACb,oKAAoK,CAAA;QACtK,MAAM,cAAc,GAClB,8GAA8G,CAAA;QAChH,MAAM,MAAM,GAAG,IAAA,2DAAwB,EAAC,SAAS,EAAE,mBAAmB,CAAC,CAAA;QACvE,MAAM,GAAG,CAAC,K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