@pie-element/ebsr 14.1.0 → 14.1.1-next.2
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/dist/author/defaults.d.ts +67 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +161 -0
- package/dist/author/index.d.ts +35 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +78 -0
- package/dist/author/main.d.ts +23 -0
- package/dist/author/main.d.ts.map +1 -0
- package/dist/author/main.js +121 -0
- package/dist/controller/defaults.d.ts +16 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +26 -0
- package/dist/controller/index.d.ts +43 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +186 -0
- package/dist/controller/utils.d.ts +11 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +8 -0
- package/dist/delivery/index.d.ts +27 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +132 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.d.ts +9 -0
- package/dist/index.iife.d.ts.map +1 -0
- package/dist/index.iife.js +165 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGet.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseToString.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_castPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIterateeCall.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKey.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_memoizeCapped.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stringToPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toKey.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/defaults.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/get.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/memoize.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toString.js +7 -0
- package/dist/print/index.d.ts +26 -0
- package/dist/print/index.d.ts.map +1 -0
- package/dist/print/index.js +107 -0
- package/package.json +59 -18
- package/{configure/src/defaults.js → src/author/defaults.ts} +10 -0
- package/{configure/src/index.js → src/author/index.ts} +16 -6
- package/{configure/src/main.jsx → src/author/main.tsx} +14 -4
- package/{controller/src/defaults.js → src/controller/defaults.ts} +10 -0
- package/{controller/src/index.js → src/controller/index.ts} +13 -3
- package/{controller/src/utils.js → src/controller/utils.ts} +10 -0
- package/src/{index.js → delivery/index.tsx} +12 -2
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
- package/src/{print.js → print/index.tsx} +12 -2
- package/CHANGELOG.json +0 -1547
- package/CHANGELOG.md +0 -2265
- package/LICENSE.md +0 -5
- package/README.md +0 -62
- package/configure/CHANGELOG.json +0 -992
- package/configure/CHANGELOG.md +0 -2130
- package/configure/lib/defaults.js +0 -229
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -154
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -222
- package/configure/lib/main.js.map +0 -1
- package/configure/package.json +0 -23
- package/configure/src/__tests__/index.test.js +0 -492
- package/controller/CHANGELOG.json +0 -552
- package/controller/CHANGELOG.md +0 -1269
- package/controller/lib/defaults.js +0 -31
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -448
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -18
- package/controller/lib/utils.js.map +0 -1
- package/controller/package.json +0 -18
- package/controller/src/__tests__/index.test.js +0 -591
- package/controller/src/__tests__/utils.test.js +0 -48
- package/docs/config-schema.json +0 -5787
- package/docs/config-schema.json.md +0 -4278
- package/docs/demo/config.js +0 -8
- package/docs/demo/generate.js +0 -52
- package/docs/demo/index.html +0 -2
- package/docs/demo/session.js +0 -14
- package/docs/pie-schema.json +0 -2911
- package/docs/pie-schema.json.md +0 -2142
- package/ebsr.png +0 -0
- package/lib/index.js +0 -207
- package/lib/index.js.map +0 -1
- package/lib/print.js +0 -186
- package/lib/print.js.map +0 -1
- package/module/configure.js +0 -1
- package/module/controller.js +0 -5664
- package/module/demo.js +0 -77
- package/module/element.js +0 -1
- package/module/index.html +0 -21
- package/module/manifest.json +0 -14
- package/module/print-demo.js +0 -115
- package/module/print.html +0 -18
- package/module/print.js +0 -1
- package/src/__tests__/index.test.js +0 -129
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SessionChangedEvent } from '@pie-framework/pie-player-events';
|
|
3
|
-
import { isSessionComplete } from '..';
|
|
4
|
-
|
|
5
|
-
jest.mock('@pie-lib/math-rendering', () => ({ renderMath: jest.fn() }));
|
|
6
|
-
jest.mock('@pie-element/multiple-choice', () => jest.fn());
|
|
7
|
-
|
|
8
|
-
const PART_A = 'partA';
|
|
9
|
-
const PART_B = 'partB';
|
|
10
|
-
|
|
11
|
-
const defaultModel = {
|
|
12
|
-
disabled: false,
|
|
13
|
-
mode: 'gather',
|
|
14
|
-
partA: {
|
|
15
|
-
choiceMode: 'radio',
|
|
16
|
-
choices: [
|
|
17
|
-
{ value: 'a', label: 'label a' },
|
|
18
|
-
{ value: 'b', label: 'label b' },
|
|
19
|
-
{ value: 'c', label: 'label c', correct: true, feedback: 'great' },
|
|
20
|
-
],
|
|
21
|
-
choicePrefix: 'numbers',
|
|
22
|
-
prompt: `prompt ${PART_A}`,
|
|
23
|
-
},
|
|
24
|
-
partB: {
|
|
25
|
-
choiceMode: 'radio',
|
|
26
|
-
choices: [
|
|
27
|
-
{ value: 'd', label: 'label d', correct: true, feedback: 'great' },
|
|
28
|
-
{ value: 'e', label: 'label e' },
|
|
29
|
-
{ value: 'f', label: 'label f' },
|
|
30
|
-
],
|
|
31
|
-
choicePrefix: 'numbers',
|
|
32
|
-
prompt: `prompt ${PART_B}`,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const defaultSession = { id: 1 };
|
|
37
|
-
|
|
38
|
-
describe('ebsr', () => {
|
|
39
|
-
let Def;
|
|
40
|
-
let el;
|
|
41
|
-
let ebsr;
|
|
42
|
-
|
|
43
|
-
beforeAll(() => {
|
|
44
|
-
Def = require('../index').default;
|
|
45
|
-
|
|
46
|
-
// Register the custom element if not already registered
|
|
47
|
-
if (!customElements.get('ebsr-element')) {
|
|
48
|
-
customElements.define('ebsr-element', Def);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
beforeEach(() => {
|
|
53
|
-
el = document.createElement('ebsr-element');
|
|
54
|
-
|
|
55
|
-
// Mock createElement for part elements
|
|
56
|
-
ebsr = {
|
|
57
|
-
partA: document.createElement('div'),
|
|
58
|
-
partB: document.createElement('div'),
|
|
59
|
-
};
|
|
60
|
-
el.querySelector = jest.fn((s) => {
|
|
61
|
-
if (s === '#part-a') {
|
|
62
|
-
return ebsr.partA;
|
|
63
|
-
} else {
|
|
64
|
-
return ebsr.partB;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Mock _render to avoid innerHTML issues with custom elements
|
|
69
|
-
el._render = jest.fn();
|
|
70
|
-
|
|
71
|
-
// Mock dispatchEvent for testing
|
|
72
|
-
el.dispatchEvent = jest.fn();
|
|
73
|
-
|
|
74
|
-
el.connectedCallback();
|
|
75
|
-
el.model = defaultModel;
|
|
76
|
-
el.session = defaultSession;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('model', () => {
|
|
80
|
-
it('should have set the model', () => {
|
|
81
|
-
expect(el._model).toEqual(defaultModel);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe('session', () => {
|
|
86
|
-
const dispatchesSessionEvent = (key, value) => {
|
|
87
|
-
it(`${key} dispatches session changed event`, () => {
|
|
88
|
-
const session = { id: key, value };
|
|
89
|
-
el.dispatchSessionChanged(session, key);
|
|
90
|
-
|
|
91
|
-
expect(el.dispatchEvent).toBeCalledWith(new SessionChangedEvent('ebsr-element', false));
|
|
92
|
-
expect(el._session.value[key]).toEqual(session);
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
it('should have set the session', () => {
|
|
97
|
-
expect(el._session).toEqual(defaultSession);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('changeAnswers', () => {
|
|
101
|
-
dispatchesSessionEvent(PART_A, 'a');
|
|
102
|
-
dispatchesSessionEvent(PART_B, 'd');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('setPartSession', () => {
|
|
107
|
-
it('sets the session object even if missing from session.value', () => {
|
|
108
|
-
const part = {};
|
|
109
|
-
el.model = {};
|
|
110
|
-
el.session = {
|
|
111
|
-
value: {},
|
|
112
|
-
};
|
|
113
|
-
el.setPartSession(part, 'partA');
|
|
114
|
-
expect(part.session).toEqual({ id: 'partA' });
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('isSessionComplete', () => {
|
|
120
|
-
const assertComplete = (s, expected) => {
|
|
121
|
-
it(`${JSON.stringify(s)} => ${expected}`, () => {
|
|
122
|
-
const result = isSessionComplete(s);
|
|
123
|
-
expect(result).toEqual(expected);
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
assertComplete({}, false);
|
|
128
|
-
assertComplete({ value: { partA: { value: [1] }, partB: { value: [2] } } }, true);
|
|
129
|
-
});
|