Fixing some regex issues and adding additional API tests

This commit is contained in:
Jonathan Putney
2020-02-04 15:14:42 -05:00
parent b272dda384
commit 0357442e93
7 changed files with 56 additions and 27 deletions
+13 -12
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -9
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "scorm-again",
"version": "1.0.1",
"version": "1.0.2",
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
"main": "dist/scorm-again.min.js",
"directories": {
+1 -1
View File
@@ -272,7 +272,7 @@ export default class Scorm2004API extends BaseAPI {
}
const response_type = correct_responses[interaction_type];
if (typeof response_type.limit !== 'undefined' || interaction_count <
if (typeof response_type.limit === 'undefined' || interaction_count <=
response_type.limit) {
let nodes = [];
if (response_type?.delimiter) {
+2 -2
View File
@@ -51,8 +51,8 @@ const scorm2004 = {
CMISInteger: '^-?([0-9]+)$',
CMIDecimal: '^-?([0-9]{1,5})(\\.[0-9]{1,18})?$',
CMIIdentifier: '^\\S{1,250}[a-zA-Z0-9]$',
CMIShortIdentifier: '^[\\w\.]{1,250}$', // eslint-disable-line
CMILongIdentifier: '^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000})$',
CMIShortIdentifier: '^[\\w\\.\\-\\_]{1,250}$', // eslint-disable-line
CMILongIdentifier: '^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$', // need to re-examine this
CMIFeedback: '^.*$', // This must be redefined
CMIIndex: '[._](\\d+).',
CMIIndexStore: '.N(\\d+).',
+29 -1
View File
@@ -296,7 +296,7 @@ describe('SCORM 2004 API Tests', () => {
valueToTest: scorm2004_values.validTimestamps[0],
errorThrown: false,
});
it('should allow cmi.interactions.0.correct_responses.0.pattern to be set',
it('should allow cmi.interactions.0.correct_responses.0.pattern to be set - T/F',
() => {
const scorm2004API = apiInitialized();
scorm2004API.setCMIValue('cmi.interactions.0.type', 'true-false');
@@ -305,6 +305,34 @@ describe('SCORM 2004 API Tests', () => {
String(scorm2004API.lmsGetLastError())
).to.equal(String(0));
});
it('should allow cmi.interactions.0.correct_responses.0.pattern to be set - choice',
() => {
const scorm2004API = apiInitialized();
scorm2004API.setCMIValue('cmi.interactions.0.id', 'Scene1_Slide3_MultiChoice_0_0');
scorm2004API.setCMIValue('cmi.interactions.0.type', 'choice');
scorm2004API.setCMIValue('cmi.interactions.0.correct_responses.0.pattern', 'VP_on-call_or_President');
expect(
String(scorm2004API.lmsGetLastError())
).to.equal(String(0));
});
it('should allow cmi.interactions.0.objectives.0.id to be set',
() => {
const scorm2004API = apiInitialized();
scorm2004API.setCMIValue('cmi.interactions.0.objectives.0.id', 'ID of the Obj - ID 2');
expect(
String(scorm2004API.lmsGetLastError())
).to.equal(String(0));
});
it('should allow cmi.interactions.0.learner_response to be set',
() => {
const scorm2004API = apiInitialized();
scorm2004API.setCMIValue('cmi.interactions.0.id', 'Scene1_Slide3_MultiChoice_0_0');
scorm2004API.setCMIValue('cmi.interactions.0.type', 'choice');
scorm2004API.setCMIValue('cmi.interactions.0.learner_response', 'VP_on-call_or_President');
expect(
String(scorm2004API.lmsGetLastError())
).to.equal(String(0));
});
});
describe('Initialized - Should Fail', () => {