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

25
dist/scorm-again.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "scorm-again", "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", "description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
"main": "dist/scorm-again.min.js", "main": "dist/scorm-again.min.js",
"directories": { "directories": {

View File

@@ -272,7 +272,7 @@ export default class Scorm2004API extends BaseAPI {
} }
const response_type = correct_responses[interaction_type]; 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) { response_type.limit) {
let nodes = []; let nodes = [];
if (response_type?.delimiter) { if (response_type?.delimiter) {

View File

@@ -51,8 +51,8 @@ const scorm2004 = {
CMISInteger: '^-?([0-9]+)$', CMISInteger: '^-?([0-9]+)$',
CMIDecimal: '^-?([0-9]{1,5})(\\.[0-9]{1,18})?$', CMIDecimal: '^-?([0-9]{1,5})(\\.[0-9]{1,18})?$',
CMIIdentifier: '^\\S{1,250}[a-zA-Z0-9]$', CMIIdentifier: '^\\S{1,250}[a-zA-Z0-9]$',
CMIShortIdentifier: '^[\\w\.]{1,250}$', // eslint-disable-line CMIShortIdentifier: '^[\\w\\.\\-\\_]{1,250}$', // eslint-disable-line
CMILongIdentifier: '^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000})$', 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 CMIFeedback: '^.*$', // This must be redefined
CMIIndex: '[._](\\d+).', CMIIndex: '[._](\\d+).',
CMIIndexStore: '.N(\\d+).', CMIIndexStore: '.N(\\d+).',

View File

@@ -296,7 +296,7 @@ describe('SCORM 2004 API Tests', () => {
valueToTest: scorm2004_values.validTimestamps[0], valueToTest: scorm2004_values.validTimestamps[0],
errorThrown: false, 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(); const scorm2004API = apiInitialized();
scorm2004API.setCMIValue('cmi.interactions.0.type', 'true-false'); scorm2004API.setCMIValue('cmi.interactions.0.type', 'true-false');
@@ -305,6 +305,34 @@ describe('SCORM 2004 API Tests', () => {
String(scorm2004API.lmsGetLastError()) String(scorm2004API.lmsGetLastError())
).to.equal(String(0)); ).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', () => { describe('Initialized - Should Fail', () => {