scorm-again 1.7.0 → 2.0.0

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.
Files changed (85) hide show
  1. package/.babelrc +18 -7
  2. package/.github/dependabot.yml +5 -0
  3. package/.github/workflows/main.yml +79 -0
  4. package/.jsdoc.json +4 -5
  5. package/.mocharc.json +8 -0
  6. package/.run/Mocha Unit Tests.run.xml +5 -2
  7. package/CONTRIBUTING.md +1 -1
  8. package/README.md +14 -1
  9. package/dist/aicc.js +3661 -7170
  10. package/dist/aicc.js.map +1 -1
  11. package/dist/aicc.min.js +2 -40
  12. package/dist/aicc.min.js.map +1 -0
  13. package/dist/scorm-again.js +5671 -10695
  14. package/dist/scorm-again.js.map +1 -1
  15. package/dist/scorm-again.min.js +2 -52
  16. package/dist/scorm-again.min.js.map +1 -0
  17. package/dist/scorm12.js +2871 -5433
  18. package/dist/scorm12.js.map +1 -1
  19. package/dist/scorm12.min.js +2 -34
  20. package/dist/scorm12.min.js.map +1 -0
  21. package/dist/scorm2004.js +3868 -6797
  22. package/dist/scorm2004.js.map +1 -1
  23. package/dist/scorm2004.min.js +2 -40
  24. package/dist/scorm2004.min.js.map +1 -0
  25. package/eslint.config.js +21 -0
  26. package/package.json +73 -35
  27. package/results.json +34254 -0
  28. package/src/{AICC.js → AICC.ts} +27 -21
  29. package/src/BaseAPI.ts +1449 -0
  30. package/src/Scorm12API.ts +360 -0
  31. package/src/{Scorm2004API.js → Scorm2004API.ts} +245 -163
  32. package/src/cmi/aicc_cmi.ts +1248 -0
  33. package/src/cmi/common.ts +411 -0
  34. package/src/cmi/scorm12_cmi.ts +1426 -0
  35. package/src/cmi/scorm2004_cmi.ts +1874 -0
  36. package/src/constants/api_constants.ts +318 -0
  37. package/src/constants/error_codes.ts +88 -0
  38. package/src/constants/language_constants.ts +394 -0
  39. package/src/constants/regex.ts +97 -0
  40. package/src/constants/{response_constants.js → response_constants.ts} +67 -62
  41. package/src/exceptions.ts +133 -0
  42. package/src/exports/aicc.js +1 -1
  43. package/src/exports/scorm-again.js +3 -3
  44. package/src/exports/scorm12.js +1 -1
  45. package/src/exports/scorm2004.js +1 -1
  46. package/src/{utilities.js → utilities.ts} +114 -74
  47. package/tea.yaml +6 -0
  48. package/test/{AICC.spec.js → AICC.spec.ts} +70 -72
  49. package/test/Scorm12API.spec.ts +580 -0
  50. package/test/Scorm2004API.spec.ts +812 -0
  51. package/test/api_helpers.ts +176 -0
  52. package/test/cmi/{aicc_cmi.spec.js → aicc_cmi.spec.ts} +193 -209
  53. package/test/cmi/{scorm12_cmi.spec.js → scorm12_cmi.spec.ts} +251 -269
  54. package/test/cmi/scorm2004_cmi.spec.ts +1031 -0
  55. package/test/cmi_helpers.ts +207 -0
  56. package/test/exceptions.spec.ts +79 -0
  57. package/test/field_values.ts +202 -0
  58. package/test/utilities.spec.ts +322 -0
  59. package/tsconfig.json +18 -0
  60. package/webpack.config.js +65 -0
  61. package/.circleci/config.yml +0 -99
  62. package/.codeclimate.yml +0 -7
  63. package/.eslintrc.js +0 -36
  64. package/src/.flowconfig +0 -11
  65. package/src/BaseAPI.js +0 -1275
  66. package/src/Scorm12API.js +0 -308
  67. package/src/cmi/aicc_cmi.js +0 -1141
  68. package/src/cmi/common.js +0 -328
  69. package/src/cmi/scorm12_cmi.js +0 -1312
  70. package/src/cmi/scorm2004_cmi.js +0 -1692
  71. package/src/constants/api_constants.js +0 -218
  72. package/src/constants/error_codes.js +0 -87
  73. package/src/constants/language_constants.js +0 -76
  74. package/src/constants/regex.js +0 -84
  75. package/src/exceptions.js +0 -104
  76. package/test/Scorm12API.spec.js +0 -528
  77. package/test/Scorm2004API.spec.js +0 -775
  78. package/test/abstract_classes.spec.js +0 -17
  79. package/test/api_helpers.js +0 -128
  80. package/test/cmi/scorm2004_cmi.spec.js +0 -1066
  81. package/test/cmi_helpers.js +0 -161
  82. package/test/exceptions.spec.js +0 -71
  83. package/test/field_values.js +0 -353
  84. package/test/utilities.spec.js +0 -339
  85. package/webpack.js +0 -78
@@ -1,17 +0,0 @@
1
- import {describe, it} from 'mocha';
2
- import {expect} from 'chai';
3
- import BaseAPI from '../src/BaseAPI';
4
- import {BaseCMI} from '../src/cmi/common';
5
-
6
- describe('Abstract Class Tests', () => {
7
- it('BaseAPI should not be instantiated', () => {
8
- expect(
9
- () => new BaseAPI(),
10
- ).to.throw('Cannot construct BaseAPI instances directly');
11
- });
12
- it('BaseCMI should not be instantiated', () => {
13
- expect(
14
- () => new BaseCMI(),
15
- ).to.throw('Cannot construct BaseCMI instances directly');
16
- });
17
- });
@@ -1,128 +0,0 @@
1
- import {describe, it} from 'mocha';
2
- import {expect} from 'chai';
3
-
4
- export const checkValidValues = (
5
- {
6
- api,
7
- fieldName,
8
- validValues,
9
- invalidValues,
10
- }) => {
11
- describe(`Field: ${fieldName}`, () => {
12
- for (const idx in validValues) {
13
- if ({}.hasOwnProperty.call(validValues, idx)) {
14
- it(`Should successfully write '${validValues[idx]}' to ${fieldName}`,
15
- () => {
16
- expect(api.lmsSetValue(fieldName, validValues[idx])).
17
- to.equal('true');
18
- });
19
- }
20
- }
21
-
22
- for (const idx in invalidValues) {
23
- if ({}.hasOwnProperty.call(invalidValues, idx)) {
24
- it(`Should fail to write '${invalidValues[idx]}' to ${fieldName}`,
25
- () => {
26
- expect(api.lmsSetValue(fieldName, invalidValues[idx])).
27
- to.equal('false');
28
- });
29
- }
30
- }
31
- });
32
- };
33
-
34
- export const checkLMSSetValue = (
35
- {
36
- api,
37
- fieldName,
38
- valueToTest = 'xxx',
39
- expectedError = 0,
40
- errorThrown = false,
41
- }) => {
42
- describe(`Field: ${fieldName}`, () => {
43
- const status = expectedError > 0 ? 'fail to' : 'successfully';
44
- it(`Should ${status} set value for ${fieldName}`, () => {
45
- if (expectedError > 0) {
46
- if (errorThrown) {
47
- expect(() => api.lmsSetValue(fieldName, valueToTest)).
48
- to.throw().with.property('errorCode', expectedError);
49
- } else {
50
- api.lmsSetValue(fieldName, valueToTest);
51
- expect(String(api.lmsGetLastError())).to.equal(String(expectedError));
52
- }
53
- } else {
54
- if (errorThrown) {
55
- expect(() => api.lmsSetValue(fieldName, valueToTest)).
56
- to.not.throw();
57
- } else {
58
- api.lmsSetValue(fieldName, valueToTest);
59
- expect(String(api.lmsGetLastError())).to.equal(String(0));
60
- }
61
- }
62
- });
63
- });
64
- };
65
-
66
- export const checkLMSGetValue = (
67
- {
68
- api,
69
- fieldName,
70
- expectedValue = '',
71
- initializeFirst = false,
72
- initializationValue = '',
73
- expectedError = 0,
74
- errorThrown = false,
75
- }) => {
76
- describe(`Field: ${fieldName}`, () => {
77
- const status = expectedError > 0 ? 'fail to' : 'successfully';
78
-
79
- if (initializeFirst) {
80
- api.setCMIValue(fieldName, initializationValue);
81
- }
82
-
83
- it(`Should ${status} get value for ${fieldName}`, () => {
84
- if (expectedError > 0) {
85
- if (errorThrown) {
86
- expect(() => api.lmsGetValue(fieldName)).
87
- to.throw().with.property('errorCode', expectedError);
88
- } else {
89
- api.lmsGetValue(fieldName);
90
- expect(String(api.lmsGetLastError())).to.equal(String(expectedError));
91
- }
92
- } else {
93
- expect(api.lmsGetValue(fieldName)).to.equal(expectedValue);
94
- }
95
- });
96
- });
97
- };
98
-
99
- export const checkSetCMIValue = (
100
- {
101
- api,
102
- fieldName,
103
- valueToTest = 'xxx',
104
- expectedError = 0,
105
- errorThrown = true,
106
- }) => {
107
- describe(`Field: ${fieldName}`, () => {
108
- const status = expectedError > 0 ? 'fail to' : 'successfully';
109
- it(`Should ${status} set CMI value for ${fieldName}`, () => {
110
- if (expectedError > 0) {
111
- if (errorThrown) {
112
- expect(() => api.setCMIValue(fieldName, valueToTest)).
113
- to.throw().with.property('errorCode', expectedError);
114
- } else {
115
- api.setCMIValue(fieldName, valueToTest);
116
- expect(String(api.lmsGetLastError())).to.equal(String(expectedError));
117
- }
118
- } else {
119
- if (errorThrown) {
120
- expect(() => api.setCMIValue(fieldName, valueToTest)).to.not.throw();
121
- } else {
122
- api.setCMIValue(fieldName, valueToTest);
123
- expect(String(api.lmsGetLastError())).to.equal(String(0));
124
- }
125
- }
126
- });
127
- });
128
- };