@pie-qti/item-player 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/catalog/applyGlossaryTriggers.d.ts +13 -2
- package/dist/catalog/applyGlossaryTriggers.d.ts.map +1 -1
- package/dist/catalog/glossaryAction.d.ts +4 -2
- package/dist/catalog/glossaryAction.d.ts.map +1 -1
- package/dist/components/utils/index.d.ts +1 -2
- package/dist/components/utils/index.d.ts.map +1 -1
- package/dist/components/utils/index.js +1 -2
- package/dist/core/ComponentRegistry.d.ts +10 -1
- package/dist/core/ComponentRegistry.d.ts.map +1 -1
- package/dist/core/ComponentRegistry.js +42 -1
- package/dist/core/Player.d.ts +10 -2
- package/dist/core/Player.d.ts.map +1 -1
- package/dist/core/Player.js +54 -46
- package/dist/document/AssessmentItemDocument.d.ts +1 -1
- package/dist/element.d.ts +15 -0
- package/dist/element.js +1817 -1625
- package/dist/element.js.map +1 -1
- package/dist/extraction/ExtractionRegistry.d.ts +1 -1
- package/dist/extraction/createContext.d.ts +1 -1
- package/dist/extraction/index.d.ts +2 -2
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +1 -1
- package/dist/extraction/interactionExtractionPipeline.d.ts +1 -1
- package/dist/extraction/interactionSecurity.d.ts +1 -1
- package/dist/extraction/types.d.ts +1 -1
- package/dist/presentation/itemPresentationPlan.d.ts +54 -0
- package/dist/presentation/itemPresentationPlan.d.ts.map +1 -0
- package/dist/presentation/itemPresentationPlan.js +98 -0
- package/dist/types/index.d.ts +17 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -3
- package/dist/web-components/QTIInteractionBase.d.ts +1 -1
- package/dist/web-components/QTIInteractionElement.d.ts +1 -1
- package/package.json +7 -14
- package/src/__tests__/catalog.test.ts +0 -267
- package/src/__tests__/fixtures/pci/echo-pci.js +0 -49
- package/src/__tests__/pci.test.ts +0 -353
- package/src/__tests__/qti3-attribute-extraction.test.ts +0 -174
- package/src/__tests__/qti3-debug.test.ts +0 -140
- package/src/__tests__/qti3-extraction.test.ts +0 -309
- package/src/catalog/applyGlossaryTriggers.ts +0 -372
- package/src/catalog/catalogExtractor.ts +0 -130
- package/src/catalog/catalogLookup.ts +0 -53
- package/src/catalog/glossaryAction.ts +0 -38
- package/src/catalog/types.ts +0 -37
- package/src/components/ItemBody.svelte +0 -363
- package/src/components/ItemPlayer.svelte +0 -163
- package/src/components/ModalFeedbackDisplay.svelte +0 -97
- package/src/components/actions/typesetAction.ts +0 -74
- package/src/components/index.ts +0 -22
- package/src/components/utils/assignProps.ts +0 -2
- package/src/components/utils/feedbackUtils.ts +0 -140
- package/src/components/utils/index.ts +0 -13
- package/src/components/utils/stimulusRender.ts +0 -93
- package/src/components/utils/stylesheetRender.ts +0 -58
- package/src/core/ComponentRegistry.ts +0 -248
- package/src/core/Player.ts +0 -1618
- package/src/core/Plugin.ts +0 -123
- package/src/core/PluginManager.ts +0 -182
- package/src/core/constants.ts +0 -117
- package/src/core/declarations.ts +0 -171
- package/src/core/parsingLimits.ts +0 -62
- package/src/core/random.ts +0 -24
- package/src/core/rolePolicy.ts +0 -34
- package/src/core/sanitizer.ts +0 -305
- package/src/core/trustedTypes.ts +0 -63
- package/src/core/urlPolicy.ts +0 -98
- package/src/document/AssessmentItemDocument.ts +0 -247
- package/src/element.ts +0 -128
- package/src/extensions/MathLiveEditor.ts +0 -313
- package/src/extraction/ExtractionRegistry.ts +0 -335
- package/src/extraction/createContext.ts +0 -52
- package/src/extraction/extractors/associateExtractor.ts +0 -1
- package/src/extraction/extractors/choiceExtractor.ts +0 -1
- package/src/extraction/extractors/conformance-qti3-advanced.test.ts +0 -239
- package/src/extraction/extractors/conformance-qti3-basic.test.ts +0 -82
- package/src/extraction/extractors/conformance.test.ts +0 -208
- package/src/extraction/extractors/customExtractor.ts +0 -1
- package/src/extraction/extractors/drawingExtractor.ts +0 -1
- package/src/extraction/extractors/endAttemptExtractor.ts +0 -1
- package/src/extraction/extractors/extendedTextExtractor.ts +0 -1
- package/src/extraction/extractors/gapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicAssociateExtractor.ts +0 -1
- package/src/extraction/extractors/graphicGapMatchExtractor.ts +0 -1
- package/src/extraction/extractors/graphicOrderExtractor.ts +0 -1
- package/src/extraction/extractors/hotspotExtractor.ts +0 -1
- package/src/extraction/extractors/hottextExtractor.ts +0 -1
- package/src/extraction/extractors/index.ts +0 -9
- package/src/extraction/extractors/inlineChoiceExtractor.ts +0 -1
- package/src/extraction/extractors/matchExtractor.ts +0 -1
- package/src/extraction/extractors/mediaExtractor.ts +0 -1
- package/src/extraction/extractors/orderExtractor.ts +0 -1
- package/src/extraction/extractors/portableCustomExtractor.ts +0 -1
- package/src/extraction/extractors/positionObjectExtractor.ts +0 -1
- package/src/extraction/extractors/selectPointExtractor.ts +0 -1
- package/src/extraction/extractors/sliderExtractor.ts +0 -1
- package/src/extraction/extractors/textEntryExtractor.ts +0 -1
- package/src/extraction/extractors/uploadExtractor.ts +0 -1
- package/src/extraction/index.ts +0 -108
- package/src/extraction/interactionExtractionPipeline.ts +0 -70
- package/src/extraction/interactionSecurity.ts +0 -60
- package/src/extraction/types.ts +0 -246
- package/src/extraction/utils.ts +0 -243
- package/src/iframe/IFramePlayerHost.ts +0 -265
- package/src/iframe/index.ts +0 -11
- package/src/iframe/protocol.ts +0 -137
- package/src/index.ts +0 -101
- package/src/interactions/associate/extractor.ts +0 -133
- package/src/interactions/associate/index.ts +0 -2
- package/src/interactions/associate/types.ts +0 -1
- package/src/interactions/choice/extractor.ts +0 -121
- package/src/interactions/choice/index.ts +0 -2
- package/src/interactions/choice/types.ts +0 -1
- package/src/interactions/custom/extractor.ts +0 -72
- package/src/interactions/custom/index.ts +0 -2
- package/src/interactions/custom/types.ts +0 -1
- package/src/interactions/drawing/extractor.ts +0 -113
- package/src/interactions/drawing/index.ts +0 -2
- package/src/interactions/drawing/types.ts +0 -1
- package/src/interactions/end-attempt/extractor.ts +0 -74
- package/src/interactions/end-attempt/index.ts +0 -2
- package/src/interactions/end-attempt/types.ts +0 -1
- package/src/interactions/extended-text/extractor.ts +0 -92
- package/src/interactions/extended-text/index.ts +0 -2
- package/src/interactions/extended-text/types.ts +0 -1
- package/src/interactions/gap-match/extractor.ts +0 -193
- package/src/interactions/gap-match/index.ts +0 -2
- package/src/interactions/gap-match/types.ts +0 -1
- package/src/interactions/graphic-associate/extractor.ts +0 -192
- package/src/interactions/graphic-associate/index.ts +0 -2
- package/src/interactions/graphic-associate/types.ts +0 -1
- package/src/interactions/graphic-gap-match/extractor.ts +0 -257
- package/src/interactions/graphic-gap-match/index.ts +0 -2
- package/src/interactions/graphic-gap-match/types.ts +0 -1
- package/src/interactions/graphic-order/extractor.ts +0 -162
- package/src/interactions/graphic-order/index.ts +0 -2
- package/src/interactions/graphic-order/types.ts +0 -1
- package/src/interactions/hotspot/extractor.ts +0 -208
- package/src/interactions/hotspot/index.ts +0 -2
- package/src/interactions/hotspot/types.ts +0 -1
- package/src/interactions/hottext/extractor.ts +0 -163
- package/src/interactions/hottext/index.ts +0 -2
- package/src/interactions/hottext/types.ts +0 -1
- package/src/interactions/index.ts +0 -52
- package/src/interactions/inline/index.ts +0 -1
- package/src/interactions/inline/render-plan.ts +0 -105
- package/src/interactions/inline-choice/InlineChoice.svelte +0 -57
- package/src/interactions/inline-choice/extractor.ts +0 -105
- package/src/interactions/inline-choice/index.ts +0 -2
- package/src/interactions/inline-choice/types.ts +0 -1
- package/src/interactions/match/extractor.ts +0 -187
- package/src/interactions/match/index.ts +0 -2
- package/src/interactions/match/types.ts +0 -1
- package/src/interactions/media/extractor.ts +0 -168
- package/src/interactions/media/index.ts +0 -2
- package/src/interactions/media/types.ts +0 -1
- package/src/interactions/modules.ts +0 -111
- package/src/interactions/order/extractor.ts +0 -120
- package/src/interactions/order/index.ts +0 -2
- package/src/interactions/order/types.ts +0 -1
- package/src/interactions/portable-custom/extractor.ts +0 -122
- package/src/interactions/portable-custom/index.ts +0 -2
- package/src/interactions/portable-custom/types.ts +0 -1
- package/src/interactions/position-object/extractor.ts +0 -243
- package/src/interactions/position-object/index.ts +0 -2
- package/src/interactions/position-object/types.ts +0 -1
- package/src/interactions/select-point/extractor.ts +0 -143
- package/src/interactions/select-point/index.ts +0 -2
- package/src/interactions/select-point/types.ts +0 -1
- package/src/interactions/shared/index.ts +0 -1
- package/src/interactions/shared/types.ts +0 -430
- package/src/interactions/slider/extractor.ts +0 -102
- package/src/interactions/slider/index.ts +0 -2
- package/src/interactions/slider/types.ts +0 -1
- package/src/interactions/text-entry/InlineTextEntry.svelte +0 -75
- package/src/interactions/text-entry/extractor.ts +0 -79
- package/src/interactions/text-entry/index.ts +0 -2
- package/src/interactions/text-entry/types.ts +0 -1
- package/src/interactions/upload/extractor.ts +0 -81
- package/src/interactions/upload/index.ts +0 -2
- package/src/interactions/upload/types.ts +0 -1
- package/src/pci/PciHost.ts +0 -138
- package/src/pci/types.ts +0 -70
- package/src/pnp/applyPnp.ts +0 -29
- package/src/pnp/parsePnpXml.ts +0 -215
- package/src/pnp/types.ts +0 -75
- package/src/server.ts +0 -14
- package/src/types/index.ts +0 -388
- package/src/types/interactions.ts +0 -8
- package/src/types/responseValidation.ts +0 -29
- package/src/types/xmldom.d.ts +0 -12
- package/src/utils/PerformanceMonitor.ts +0 -335
- package/src/utils/drawingUtils.ts +0 -73
- package/src/utils/responseUtils.ts +0 -51
- package/src/utils/touchDragHelper.ts +0 -1
- package/src/web-components/QTIInteractionBase.ts +0 -303
- package/src/web-components/QTIInteractionElement.ts +0 -125
- package/src/web-components/index.ts +0 -22
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'bun:test';
|
|
2
|
-
import { extractCatalog, extractCatalogFromItemXml, mergeCatalogs } from '../catalog/catalogExtractor.js';
|
|
3
|
-
import { getCatalogEntry } from '../catalog/catalogLookup.js';
|
|
4
|
-
import { Player } from '../core/Player.js';
|
|
5
|
-
|
|
6
|
-
// ---------------------------------------------------------------------------
|
|
7
|
-
// extractCatalog
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
|
|
10
|
-
const CATALOG_XML = `
|
|
11
|
-
<qti-catalog-info>
|
|
12
|
-
<qti-card identifier="term-photosynthesis">
|
|
13
|
-
<qti-card-entry usage="glossary-on-screen" xml:lang="en-US">
|
|
14
|
-
<qti-html-content>The process by which plants make food using sunlight.</qti-html-content>
|
|
15
|
-
</qti-card-entry>
|
|
16
|
-
<qti-card-entry usage="glossary-on-screen" xml:lang="es">
|
|
17
|
-
<qti-html-content>El proceso por el cual las plantas producen alimento usando la luz solar.</qti-html-content>
|
|
18
|
-
</qti-card-entry>
|
|
19
|
-
<qti-card-entry usage="keyword-translation" xml:lang="es">
|
|
20
|
-
<qti-html-content>fotosíntesis</qti-html-content>
|
|
21
|
-
</qti-card-entry>
|
|
22
|
-
<qti-card-entry usage="illustrated-glossary">
|
|
23
|
-
<qti-file-href src="https://example.com/photosynthesis.png"/>
|
|
24
|
-
</qti-card-entry>
|
|
25
|
-
<qti-card-entry usage="tts-pronunciation">
|
|
26
|
-
<qti-html-content>fo-to-SIN-the-sis</qti-html-content>
|
|
27
|
-
</qti-card-entry>
|
|
28
|
-
<qti-card-entry usage="signing-definition">
|
|
29
|
-
<qti-file-href src="https://example.com/sign-photo.mp4"/>
|
|
30
|
-
</qti-card-entry>
|
|
31
|
-
<qti-card-entry usage="braille-text">
|
|
32
|
-
<qti-html-content>⠏⠓⠕⠞⠕⠎⠽⠝⠞⠓⠑⠎⠊⠎</qti-html-content>
|
|
33
|
-
</qti-card-entry>
|
|
34
|
-
<qti-card-entry usage="audio-description">
|
|
35
|
-
<qti-file-href src="https://example.com/audio-photo.mp3"/>
|
|
36
|
-
</qti-card-entry>
|
|
37
|
-
<qti-card-entry usage="extended-description">
|
|
38
|
-
<qti-html-content><p>Photosynthesis occurs in the chloroplasts of plant cells.</p></qti-html-content>
|
|
39
|
-
</qti-card-entry>
|
|
40
|
-
</qti-card>
|
|
41
|
-
</qti-catalog-info>
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
describe('extractCatalog', () => {
|
|
45
|
-
it('returns empty map for empty input', () => {
|
|
46
|
-
expect(extractCatalog('').size).toBe(0);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('returns empty map when no qti-catalog-info present', () => {
|
|
50
|
-
expect(extractCatalog('<div>nothing</div>').size).toBe(0);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('parses a card and returns it by identifier', () => {
|
|
54
|
-
const index = extractCatalog(CATALOG_XML);
|
|
55
|
-
expect(index.has('term-photosynthesis')).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('parses all 8 standard usage types', () => {
|
|
59
|
-
const index = extractCatalog(CATALOG_XML);
|
|
60
|
-
const card = index.get('term-photosynthesis')!;
|
|
61
|
-
const usages = card.entries.map((e) => e.usage);
|
|
62
|
-
expect(usages).toContain('glossary-on-screen');
|
|
63
|
-
expect(usages).toContain('keyword-translation');
|
|
64
|
-
expect(usages).toContain('illustrated-glossary');
|
|
65
|
-
expect(usages).toContain('tts-pronunciation');
|
|
66
|
-
expect(usages).toContain('signing-definition');
|
|
67
|
-
expect(usages).toContain('braille-text');
|
|
68
|
-
expect(usages).toContain('audio-description');
|
|
69
|
-
expect(usages).toContain('extended-description');
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('captures xml:lang on entries', () => {
|
|
73
|
-
const index = extractCatalog(CATALOG_XML);
|
|
74
|
-
const card = index.get('term-photosynthesis')!;
|
|
75
|
-
const enEntry = card.entries.find((e) => e.usage === 'glossary-on-screen' && e.lang === 'en-US');
|
|
76
|
-
expect(enEntry).toBeDefined();
|
|
77
|
-
expect(enEntry!.html).toContain('plants make food');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('captures src from qti-file-href for media entries', () => {
|
|
81
|
-
const index = extractCatalog(CATALOG_XML);
|
|
82
|
-
const card = index.get('term-photosynthesis')!;
|
|
83
|
-
const imgEntry = card.entries.find((e) => e.usage === 'illustrated-glossary');
|
|
84
|
-
expect(imgEntry?.html).toContain('photosynthesis.png');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('parses multiple xml:lang variants for same usage', () => {
|
|
88
|
-
const index = extractCatalog(CATALOG_XML);
|
|
89
|
-
const card = index.get('term-photosynthesis')!;
|
|
90
|
-
const glossaryEntries = card.entries.filter((e) => e.usage === 'glossary-on-screen');
|
|
91
|
-
expect(glossaryEntries.length).toBe(2);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// mergeCatalogs
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
|
|
99
|
-
describe('mergeCatalogs', () => {
|
|
100
|
-
it('item-level entries win on collision', () => {
|
|
101
|
-
const base = extractCatalog(`
|
|
102
|
-
<qti-catalog-info>
|
|
103
|
-
<qti-card identifier="term-A">
|
|
104
|
-
<qti-card-entry usage="glossary-on-screen">
|
|
105
|
-
<qti-html-content>Base definition</qti-html-content>
|
|
106
|
-
</qti-card-entry>
|
|
107
|
-
</qti-card>
|
|
108
|
-
</qti-catalog-info>
|
|
109
|
-
`);
|
|
110
|
-
const override = extractCatalog(`
|
|
111
|
-
<qti-catalog-info>
|
|
112
|
-
<qti-card identifier="term-A">
|
|
113
|
-
<qti-card-entry usage="glossary-on-screen">
|
|
114
|
-
<qti-html-content>Item definition</qti-html-content>
|
|
115
|
-
</qti-card-entry>
|
|
116
|
-
</qti-card>
|
|
117
|
-
</qti-catalog-info>
|
|
118
|
-
`);
|
|
119
|
-
const merged = mergeCatalogs(base, override);
|
|
120
|
-
const entry = merged.get('term-A')!.entries[0];
|
|
121
|
-
expect(entry.html).toBe('Item definition');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('shared-only entries are present in merged result', () => {
|
|
125
|
-
const shared = extractCatalog(`
|
|
126
|
-
<qti-catalog-info>
|
|
127
|
-
<qti-card identifier="shared-term">
|
|
128
|
-
<qti-card-entry usage="glossary-on-screen">
|
|
129
|
-
<qti-html-content>Shared def</qti-html-content>
|
|
130
|
-
</qti-card-entry>
|
|
131
|
-
</qti-card>
|
|
132
|
-
</qti-catalog-info>
|
|
133
|
-
`);
|
|
134
|
-
const item = extractCatalog(`
|
|
135
|
-
<qti-catalog-info>
|
|
136
|
-
<qti-card identifier="item-term">
|
|
137
|
-
<qti-card-entry usage="glossary-on-screen">
|
|
138
|
-
<qti-html-content>Item def</qti-html-content>
|
|
139
|
-
</qti-card-entry>
|
|
140
|
-
</qti-card>
|
|
141
|
-
</qti-catalog-info>
|
|
142
|
-
`);
|
|
143
|
-
const merged = mergeCatalogs(shared, item);
|
|
144
|
-
expect(merged.has('shared-term')).toBe(true);
|
|
145
|
-
expect(merged.has('item-term')).toBe(true);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// ---------------------------------------------------------------------------
|
|
150
|
-
// getCatalogEntry — language fallback
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
|
|
153
|
-
function makeSingleCardIndex(lang?: string): ReturnType<typeof extractCatalog> {
|
|
154
|
-
const langAttr = lang ? ` xml:lang="${lang}"` : '';
|
|
155
|
-
return extractCatalog(`
|
|
156
|
-
<qti-catalog-info>
|
|
157
|
-
<qti-card identifier="t1">
|
|
158
|
-
<qti-card-entry usage="glossary-on-screen"${langAttr}>
|
|
159
|
-
<qti-html-content>def:${lang ?? 'nolang'}</qti-html-content>
|
|
160
|
-
</qti-card-entry>
|
|
161
|
-
</qti-card>
|
|
162
|
-
</qti-catalog-info>
|
|
163
|
-
`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
describe('getCatalogEntry', () => {
|
|
167
|
-
it('returns null when identifier not found', () => {
|
|
168
|
-
const index = extractCatalog(CATALOG_XML);
|
|
169
|
-
expect(getCatalogEntry(index, 'no-such-term', 'glossary-on-screen')).toBeNull();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('returns null when usage not found for known identifier', () => {
|
|
173
|
-
const index = extractCatalog(CATALOG_XML);
|
|
174
|
-
expect(getCatalogEntry(index, 'term-photosynthesis', 'no-such-usage')).toBeNull();
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('returns exact language match first', () => {
|
|
178
|
-
const index = extractCatalog(CATALOG_XML);
|
|
179
|
-
const result = getCatalogEntry(index, 'term-photosynthesis', 'glossary-on-screen', 'en-US');
|
|
180
|
-
expect(result).toContain('plants make food');
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('falls back to language prefix (en-US request → en entry)', () => {
|
|
184
|
-
const index = makeSingleCardIndex('en');
|
|
185
|
-
const result = getCatalogEntry(index, 't1', 'glossary-on-screen', 'en-US');
|
|
186
|
-
expect(result).toBe('def:en');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('falls back to language prefix (en request → en-US entry)', () => {
|
|
190
|
-
const index = makeSingleCardIndex('en-US');
|
|
191
|
-
const result = getCatalogEntry(index, 't1', 'glossary-on-screen', 'en');
|
|
192
|
-
expect(result).toBe('def:en-US');
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('falls back to no-lang entry when language does not match', () => {
|
|
196
|
-
const index = makeSingleCardIndex(undefined);
|
|
197
|
-
const result = getCatalogEntry(index, 't1', 'glossary-on-screen', 'fr');
|
|
198
|
-
expect(result).toBe('def:nolang');
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('returns entry when no language requested and entry has no lang', () => {
|
|
202
|
-
const index = makeSingleCardIndex(undefined);
|
|
203
|
-
const result = getCatalogEntry(index, 't1', 'glossary-on-screen');
|
|
204
|
-
expect(result).toBe('def:nolang');
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// ---------------------------------------------------------------------------
|
|
209
|
-
// Player.getCatalogEntry integration
|
|
210
|
-
// ---------------------------------------------------------------------------
|
|
211
|
-
|
|
212
|
-
const ITEM_WITH_CATALOG = `<?xml version="1.0" encoding="UTF-8"?>
|
|
213
|
-
<qti-assessment-item
|
|
214
|
-
xmlns="http://www.imsglobal.org/xsd/imsqtiasi_v3p0"
|
|
215
|
-
identifier="catalog-test" title="Catalog Test" adaptive="false" time-dependent="false">
|
|
216
|
-
<qti-response-declaration identifier="RESPONSE" cardinality="single" base-type="identifier"/>
|
|
217
|
-
<qti-outcome-declaration identifier="SCORE" cardinality="single" base-type="float"/>
|
|
218
|
-
<qti-catalog-info>
|
|
219
|
-
<qti-card identifier="word-mitosis">
|
|
220
|
-
<qti-card-entry usage="glossary-on-screen" xml:lang="en">
|
|
221
|
-
<qti-html-content>Division of a cell into two daughter cells.</qti-html-content>
|
|
222
|
-
</qti-card-entry>
|
|
223
|
-
</qti-card>
|
|
224
|
-
</qti-catalog-info>
|
|
225
|
-
<qti-item-body>
|
|
226
|
-
<p>The process of <span data-catalog-idref="word-mitosis">mitosis</span> produces two identical cells.</p>
|
|
227
|
-
<qti-choice-interaction response-identifier="RESPONSE" max-choices="1">
|
|
228
|
-
<qti-simple-choice identifier="A">True</qti-simple-choice>
|
|
229
|
-
<qti-simple-choice identifier="B">False</qti-simple-choice>
|
|
230
|
-
</qti-choice-interaction>
|
|
231
|
-
</qti-item-body>
|
|
232
|
-
</qti-assessment-item>`;
|
|
233
|
-
|
|
234
|
-
describe('Player catalog integration', () => {
|
|
235
|
-
it('getCatalogEntry returns the embedded catalog entry', () => {
|
|
236
|
-
const player = new Player({ itemXml: ITEM_WITH_CATALOG });
|
|
237
|
-
const result = player.getCatalogEntry('word-mitosis', 'glossary-on-screen', 'en');
|
|
238
|
-
expect(result).toContain('daughter cells');
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('getCatalogEntry returns null for unknown term', () => {
|
|
242
|
-
const player = new Player({ itemXml: ITEM_WITH_CATALOG });
|
|
243
|
-
expect(player.getCatalogEntry('no-such-word', 'glossary-on-screen')).toBeNull();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('shared catalogXml is merged with item catalog; item wins on collision', () => {
|
|
247
|
-
const sharedXml = `
|
|
248
|
-
<qti-catalog-info>
|
|
249
|
-
<qti-card identifier="word-mitosis">
|
|
250
|
-
<qti-card-entry usage="glossary-on-screen">
|
|
251
|
-
<qti-html-content>Shared definition (should be overridden)</qti-html-content>
|
|
252
|
-
</qti-card-entry>
|
|
253
|
-
</qti-card>
|
|
254
|
-
<qti-card identifier="shared-only-word">
|
|
255
|
-
<qti-card-entry usage="glossary-on-screen">
|
|
256
|
-
<qti-html-content>Shared-only definition</qti-html-content>
|
|
257
|
-
</qti-card-entry>
|
|
258
|
-
</qti-card>
|
|
259
|
-
</qti-catalog-info>
|
|
260
|
-
`;
|
|
261
|
-
const player = new Player({ itemXml: ITEM_WITH_CATALOG, catalogXml: sharedXml });
|
|
262
|
-
// Item-level wins
|
|
263
|
-
expect(player.getCatalogEntry('word-mitosis', 'glossary-on-screen', 'en')).toContain('daughter cells');
|
|
264
|
-
// Shared-only entry is accessible
|
|
265
|
-
expect(player.getCatalogEntry('shared-only-word', 'glossary-on-screen')).toContain('Shared-only');
|
|
266
|
-
});
|
|
267
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal echo PCI for tests.
|
|
3
|
-
* initialize() renders a text input, fires onReady, and wires onResponseChange.
|
|
4
|
-
* getResponse/setResponse/disable/enable/destroy all work as expected.
|
|
5
|
-
*/
|
|
6
|
-
export default {
|
|
7
|
-
_value: '',
|
|
8
|
-
_input: null,
|
|
9
|
-
_disabled: false,
|
|
10
|
-
_destroyed: false,
|
|
11
|
-
|
|
12
|
-
initialize(dom, _config, boundTo) {
|
|
13
|
-
const input = document.createElement('input');
|
|
14
|
-
input.type = 'text';
|
|
15
|
-
input.value = this._value;
|
|
16
|
-
input.addEventListener('input', () => {
|
|
17
|
-
this._value = input.value;
|
|
18
|
-
boundTo.onResponseChange(this._value);
|
|
19
|
-
});
|
|
20
|
-
this._input = input;
|
|
21
|
-
dom.appendChild(input);
|
|
22
|
-
boundTo.onReady();
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
getResponse() {
|
|
26
|
-
return this._value;
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
setResponse(value) {
|
|
30
|
-
this._value = String(value ?? '');
|
|
31
|
-
if (this._input) this._input.value = this._value;
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
disable() {
|
|
35
|
-
this._disabled = true;
|
|
36
|
-
if (this._input) this._input.disabled = true;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
enable() {
|
|
40
|
-
this._disabled = false;
|
|
41
|
-
if (this._input) this._input.disabled = false;
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
destroy() {
|
|
45
|
-
this._destroyed = true;
|
|
46
|
-
this._input?.remove();
|
|
47
|
-
this._input = null;
|
|
48
|
-
},
|
|
49
|
-
};
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, mock } from 'bun:test';
|
|
2
|
-
import { PciHost } from '../pci/PciHost.js';
|
|
3
|
-
import { PciLoadError } from '../pci/types.js';
|
|
4
|
-
import type { ExtractedPci, PciModule } from '../pci/types.js';
|
|
5
|
-
import { portableCustomExtractor } from '../extraction/extractors/portableCustomExtractor.js';
|
|
6
|
-
import { createExtractionUtils } from '../extraction/index.js';
|
|
7
|
-
import { Qti3AttributeNameMapper, Qti3ElementNameMapper } from '@pie-qti/qti-common';
|
|
8
|
-
import { parse } from 'node-html-parser';
|
|
9
|
-
|
|
10
|
-
// ---------------------------------------------------------------------------
|
|
11
|
-
// Helpers
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
|
|
14
|
-
function makeData(overrides: Partial<ExtractedPci> = {}): ExtractedPci {
|
|
15
|
-
return {
|
|
16
|
-
responseIdentifier: 'RESPONSE',
|
|
17
|
-
customInteractionTypeIdentifier: 'urn:test:echo-pci',
|
|
18
|
-
primaryPath: 'https://cdn.example.com/pci/echo.js',
|
|
19
|
-
fallbackPath: 'https://cdn.example.com/pci/echo-fallback.js',
|
|
20
|
-
markup: '<div class="pci-container"></div>',
|
|
21
|
-
config: { color: 'blue', maxLength: '200' },
|
|
22
|
-
...overrides,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function makeModule(overrides: Partial<PciModule> = {}): PciModule {
|
|
27
|
-
return {
|
|
28
|
-
initialize: mock(() => {}),
|
|
29
|
-
getResponse: mock(() => 'test-response'),
|
|
30
|
-
setResponse: mock(() => {}),
|
|
31
|
-
disable: mock(() => {}),
|
|
32
|
-
enable: mock(() => {}),
|
|
33
|
-
destroy: mock(() => {}),
|
|
34
|
-
...overrides,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Fake DOM node (minimal — just needs appendChild) */
|
|
39
|
-
function makeDomNode() {
|
|
40
|
-
return {
|
|
41
|
-
appendChild: mock((_el: any) => {}),
|
|
42
|
-
} as any as HTMLElement;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
// PciHost — constructor
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
|
|
49
|
-
describe('PciHost', () => {
|
|
50
|
-
it('instantiates without throwing', () => {
|
|
51
|
-
expect(() => new PciHost(makeData(), 'https://host.example.com')).not.toThrow();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// ---------------------------------------------------------------------------
|
|
55
|
-
// PciHost.load()
|
|
56
|
-
// ---------------------------------------------------------------------------
|
|
57
|
-
|
|
58
|
-
it('load() resolves when dynamic import succeeds with default export', async () => {
|
|
59
|
-
const module = makeModule();
|
|
60
|
-
const host = new PciHost(makeData({ primaryPath: 'https://cdn.example.com/good.js' }), '');
|
|
61
|
-
|
|
62
|
-
// Patch import to resolve with default export
|
|
63
|
-
(host as any).resolveUrl = () => 'mocked';
|
|
64
|
-
(host as any).dynamicImport = mock(async (_url: string) => ({ default: module }));
|
|
65
|
-
|
|
66
|
-
await host.load();
|
|
67
|
-
// Should not throw — module is loaded
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('load() falls back to fallbackPath when primary import throws', async () => {
|
|
71
|
-
const module = makeModule();
|
|
72
|
-
const host = new PciHost(makeData(), '');
|
|
73
|
-
|
|
74
|
-
let callCount = 0;
|
|
75
|
-
(host as any).dynamicImport = mock(async (_url: string) => {
|
|
76
|
-
callCount++;
|
|
77
|
-
if (callCount === 1) throw new Error('primary failed');
|
|
78
|
-
return { default: module };
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
await host.load();
|
|
82
|
-
expect(callCount).toBe(2);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('load() throws PciLoadError when both primary and fallback fail', async () => {
|
|
86
|
-
const host = new PciHost(makeData(), '');
|
|
87
|
-
|
|
88
|
-
(host as any).dynamicImport = mock(async () => {
|
|
89
|
-
throw new Error('not found');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
await expect(host.load()).rejects.toBeInstanceOf(PciLoadError);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('load() throws PciLoadError when only primary fails and no fallback', async () => {
|
|
96
|
-
const host = new PciHost(makeData({ fallbackPath: undefined }), '');
|
|
97
|
-
|
|
98
|
-
(host as any).dynamicImport = mock(async () => {
|
|
99
|
-
throw new Error('not found');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
await expect(host.load()).rejects.toBeInstanceOf(PciLoadError);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('PciLoadError includes primaryPath and fallbackPath', async () => {
|
|
106
|
-
const data = makeData();
|
|
107
|
-
const host = new PciHost(data, '');
|
|
108
|
-
|
|
109
|
-
(host as any).dynamicImport = mock(async () => {
|
|
110
|
-
throw new Error('not found');
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
let err: PciLoadError | null = null;
|
|
114
|
-
try {
|
|
115
|
-
await host.load();
|
|
116
|
-
} catch (e) {
|
|
117
|
-
err = e as PciLoadError;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
expect(err).toBeInstanceOf(PciLoadError);
|
|
121
|
-
expect(err!.primaryPath).toBe(data.primaryPath);
|
|
122
|
-
expect(err!.fallbackPath).toBe(data.fallbackPath);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// ---------------------------------------------------------------------------
|
|
126
|
-
// PciHost.initialize()
|
|
127
|
-
// ---------------------------------------------------------------------------
|
|
128
|
-
|
|
129
|
-
it('initialize() calls module.initialize with dom, config, and boundTo', () => {
|
|
130
|
-
const module = makeModule();
|
|
131
|
-
const host = new PciHost(makeData(), '');
|
|
132
|
-
(host as any).module = module;
|
|
133
|
-
|
|
134
|
-
const dom = makeDomNode();
|
|
135
|
-
host.initialize(dom);
|
|
136
|
-
|
|
137
|
-
expect(module.initialize).toHaveBeenCalledTimes(1);
|
|
138
|
-
const [calledDom, calledConfig, calledBoundTo] = (module.initialize as any).mock.calls[0];
|
|
139
|
-
expect(calledDom).toBe(dom);
|
|
140
|
-
expect(calledConfig).toEqual({ color: 'blue', maxLength: '200' });
|
|
141
|
-
expect(typeof calledBoundTo.onReady).toBe('function');
|
|
142
|
-
expect(typeof calledBoundTo.onResponseChange).toBe('function');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('initialize() is a no-op when module has not been loaded', () => {
|
|
146
|
-
const host = new PciHost(makeData(), '');
|
|
147
|
-
// Should not throw even though module is null
|
|
148
|
-
expect(() => host.initialize(makeDomNode())).not.toThrow();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
// PciHost response handling
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
|
-
|
|
155
|
-
it('getResponse() delegates to module.getResponse()', () => {
|
|
156
|
-
const module = makeModule({ getResponse: mock(() => 'hello') });
|
|
157
|
-
const host = new PciHost(makeData(), '');
|
|
158
|
-
(host as any).module = module;
|
|
159
|
-
|
|
160
|
-
expect(host.getResponse()).toBe('hello');
|
|
161
|
-
expect(module.getResponse).toHaveBeenCalledTimes(1);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('setResponse() delegates to module.setResponse()', () => {
|
|
165
|
-
const module = makeModule();
|
|
166
|
-
const host = new PciHost(makeData(), '');
|
|
167
|
-
(host as any).module = module;
|
|
168
|
-
|
|
169
|
-
host.setResponse('world');
|
|
170
|
-
expect(module.setResponse).toHaveBeenCalledWith('world');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('onResponseChange callback fires when boundTo.onResponseChange is called', () => {
|
|
174
|
-
const module = makeModule();
|
|
175
|
-
const host = new PciHost(makeData(), '');
|
|
176
|
-
(host as any).module = module;
|
|
177
|
-
|
|
178
|
-
const received: Array<[string, unknown]> = [];
|
|
179
|
-
host.onResponseChange((id, val) => received.push([id, val]));
|
|
180
|
-
|
|
181
|
-
const dom = makeDomNode();
|
|
182
|
-
host.initialize(dom);
|
|
183
|
-
|
|
184
|
-
// Simulate PCI calling boundTo.onResponseChange
|
|
185
|
-
const boundTo = (module.initialize as any).mock.calls[0][2];
|
|
186
|
-
boundTo.onResponseChange('answer-42');
|
|
187
|
-
|
|
188
|
-
expect(received).toEqual([['RESPONSE', 'answer-42']]);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// ---------------------------------------------------------------------------
|
|
192
|
-
// PciHost lifecycle
|
|
193
|
-
// ---------------------------------------------------------------------------
|
|
194
|
-
|
|
195
|
-
it('disable() delegates to module.disable()', () => {
|
|
196
|
-
const module = makeModule();
|
|
197
|
-
const host = new PciHost(makeData(), '');
|
|
198
|
-
(host as any).module = module;
|
|
199
|
-
|
|
200
|
-
host.disable();
|
|
201
|
-
expect(module.disable).toHaveBeenCalledTimes(1);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it('enable() delegates to module.enable()', () => {
|
|
205
|
-
const module = makeModule();
|
|
206
|
-
const host = new PciHost(makeData(), '');
|
|
207
|
-
(host as any).module = module;
|
|
208
|
-
|
|
209
|
-
host.enable();
|
|
210
|
-
expect(module.enable).toHaveBeenCalledTimes(1);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('destroy() calls module.destroy() and nullifies module', () => {
|
|
214
|
-
const module = makeModule();
|
|
215
|
-
const host = new PciHost(makeData(), '');
|
|
216
|
-
(host as any).module = module;
|
|
217
|
-
|
|
218
|
-
host.destroy();
|
|
219
|
-
expect(module.destroy).toHaveBeenCalledTimes(1);
|
|
220
|
-
expect((host as any).module).toBeNull();
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('disable/enable/destroy are no-ops before load()', () => {
|
|
224
|
-
const host = new PciHost(makeData(), '');
|
|
225
|
-
expect(() => { host.disable(); host.enable(); host.destroy(); }).not.toThrow();
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// ---------------------------------------------------------------------------
|
|
229
|
-
// URL resolution
|
|
230
|
-
// ---------------------------------------------------------------------------
|
|
231
|
-
|
|
232
|
-
it('resolveUrl returns absolute URLs unchanged', () => {
|
|
233
|
-
const host = new PciHost(makeData(), 'https://base.example.com/items/');
|
|
234
|
-
expect((host as any).resolveUrl('https://cdn.example.com/pci.js')).toBe('https://cdn.example.com/pci.js');
|
|
235
|
-
expect((host as any).resolveUrl('/absolute/path.js')).toBe('/absolute/path.js');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it('resolveUrl prepends baseUrl for relative paths', () => {
|
|
239
|
-
const host = new PciHost(makeData(), 'https://base.example.com/items/');
|
|
240
|
-
expect((host as any).resolveUrl('pci/echo.js')).toBe('https://base.example.com/items/pci/echo.js');
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('resolveUrl adds trailing slash to baseUrl if missing', () => {
|
|
244
|
-
const host = new PciHost(makeData(), 'https://base.example.com/items');
|
|
245
|
-
expect((host as any).resolveUrl('pci/echo.js')).toBe('https://base.example.com/items/pci/echo.js');
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
// ---------------------------------------------------------------------------
|
|
250
|
-
// portableCustomExtractor
|
|
251
|
-
// ---------------------------------------------------------------------------
|
|
252
|
-
|
|
253
|
-
const PCI_XML = `
|
|
254
|
-
<qti-portable-custom-interaction
|
|
255
|
-
response-identifier="PCI_RESPONSE"
|
|
256
|
-
custom-interaction-type-identifier="urn:example:echo-pci">
|
|
257
|
-
<qti-interaction-modules>
|
|
258
|
-
<qti-interaction-module
|
|
259
|
-
id="echoModule"
|
|
260
|
-
primary-path="pci/echo.js"
|
|
261
|
-
fallback-path="pci/echo-fallback.js"/>
|
|
262
|
-
</qti-interaction-modules>
|
|
263
|
-
<qti-interaction-markup>
|
|
264
|
-
<div class="echo-container">Enter text here</div>
|
|
265
|
-
</qti-interaction-markup>
|
|
266
|
-
<qti-pci-properties>
|
|
267
|
-
<qti-pci-property key="theme" value="light"/>
|
|
268
|
-
<qti-pci-property key="maxLength" value="500"/>
|
|
269
|
-
</qti-pci-properties>
|
|
270
|
-
</qti-portable-custom-interaction>
|
|
271
|
-
`;
|
|
272
|
-
|
|
273
|
-
function parseEl(xml: string) {
|
|
274
|
-
const doc = parse(xml.trim(), { lowerCaseTagName: false, comment: false });
|
|
275
|
-
return (doc.firstChild ?? doc) as any;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function makeContext(el: any) {
|
|
279
|
-
const utils = createExtractionUtils(undefined, new Qti3ElementNameMapper(), new Qti3AttributeNameMapper());
|
|
280
|
-
return { element: el, responseId: 'PCI_RESPONSE', dom: el, declarations: new Map(), utils, config: {} as any };
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
describe('portableCustomExtractor', () => {
|
|
284
|
-
it('canHandle returns true for qti-portable-custom-interaction', () => {
|
|
285
|
-
const el = parseEl(PCI_XML);
|
|
286
|
-
expect(portableCustomExtractor.canHandle(el, makeContext(el))).toBe(true);
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
it('canHandle returns false for qti-choice-interaction', () => {
|
|
290
|
-
const el = parseEl('<qti-choice-interaction response-identifier="R" max-choices="1"/>');
|
|
291
|
-
expect(portableCustomExtractor.canHandle(el, makeContext(el))).toBe(false);
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
it('extracts responseIdentifier', () => {
|
|
295
|
-
const el = parseEl(PCI_XML);
|
|
296
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
297
|
-
expect(data.responseIdentifier).toBe('PCI_RESPONSE');
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
it('extracts customInteractionTypeIdentifier', () => {
|
|
301
|
-
const el = parseEl(PCI_XML);
|
|
302
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
303
|
-
expect(data.customInteractionTypeIdentifier).toBe('urn:example:echo-pci');
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
it('extracts primaryPath from qti-interaction-module', () => {
|
|
307
|
-
const el = parseEl(PCI_XML);
|
|
308
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
309
|
-
expect(data.primaryPath).toBe('pci/echo.js');
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it('extracts fallbackPath from qti-interaction-module', () => {
|
|
313
|
-
const el = parseEl(PCI_XML);
|
|
314
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
315
|
-
expect(data.fallbackPath).toBe('pci/echo-fallback.js');
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
it('extracts markup from qti-interaction-markup', () => {
|
|
319
|
-
const el = parseEl(PCI_XML);
|
|
320
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
321
|
-
expect(data.markup).toContain('echo-container');
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('extracts config key/value pairs from qti-pci-properties', () => {
|
|
325
|
-
const el = parseEl(PCI_XML);
|
|
326
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
327
|
-
expect(data.config.theme).toBe('light');
|
|
328
|
-
expect(data.config.maxLength).toBe('500');
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it('validate returns invalid when primaryPath is empty', () => {
|
|
332
|
-
const result = portableCustomExtractor.validate!({
|
|
333
|
-
responseIdentifier: 'R',
|
|
334
|
-
customInteractionTypeIdentifier: 'urn:x',
|
|
335
|
-
primaryPath: '',
|
|
336
|
-
markup: '',
|
|
337
|
-
config: {},
|
|
338
|
-
});
|
|
339
|
-
expect(result.valid).toBe(false);
|
|
340
|
-
expect(result.errors).toBeDefined();
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('validate returns valid for a well-formed ExtractedPci', () => {
|
|
344
|
-
const el = parseEl(PCI_XML);
|
|
345
|
-
const data = portableCustomExtractor.extract(el, makeContext(el));
|
|
346
|
-
const result = portableCustomExtractor.validate!(data);
|
|
347
|
-
expect(result.valid).toBe(true);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
it('has higher priority than standardCustomExtractor (10)', () => {
|
|
351
|
-
expect(portableCustomExtractor.priority).toBeGreaterThan(10);
|
|
352
|
-
});
|
|
353
|
-
});
|