Rework of constants and some additional tests
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import * as h from './api_helpers';
|
||||
import {scorm12_error_codes} from '../src/constants/error_codes';
|
||||
import ErrorCodes from '../src/constants/error_codes';
|
||||
import AICC from '../src/AICC';
|
||||
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const api = () => {
|
||||
const API = new AICC();
|
||||
API.apiLogLevel = 1;
|
||||
|
||||
@@ -2,9 +2,11 @@ import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import Scorm12API from '../src/Scorm12API';
|
||||
import * as h from './api_helpers';
|
||||
import {scorm12_error_codes} from '../src/constants/error_codes';
|
||||
import ErrorCodes from '../src/constants/error_codes';
|
||||
import {scorm12_values} from './field_values';
|
||||
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const api = (settings = {}) => {
|
||||
const API = new Scorm12API(settings);
|
||||
API.apiLogLevel = 1;
|
||||
@@ -278,6 +280,11 @@ describe('SCORM 1.2 API Tests', () => {
|
||||
fieldName: 'cmi.interactions.0.id',
|
||||
valueToTest: 'AAA',
|
||||
});
|
||||
h.checkLMSSetValue({
|
||||
api: apiInitialized(),
|
||||
fieldName: 'cmi.interactions.0.correct_responses.0.pattern',
|
||||
valueToTest: 't',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -307,6 +314,24 @@ describe('SCORM 1.2 API Tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('renderCommitCMI()', () => {
|
||||
it('if the user passes, should calculate total time when terminateCommit passed',
|
||||
() => {
|
||||
const scorm12API = api();
|
||||
scorm12API.cmi.core.score.max = '100';
|
||||
scorm12API.cmi.core.score.min = '0';
|
||||
scorm12API.cmi.core.score.raw = '100';
|
||||
scorm12API.cmi.core.exit = 'suspend';
|
||||
scorm12API.cmi.core.lesson_status = 'completed';
|
||||
scorm12API.cmi.core.total_time = '0000:00:00';
|
||||
scorm12API.cmi.core.session_time = '23:59:59';
|
||||
const cmiExport = scorm12API.renderCommitCMI(true);
|
||||
expect(
|
||||
cmiExport.cmi.core.total_time,
|
||||
).to.equal('23:59:59');
|
||||
});
|
||||
});
|
||||
|
||||
describe('storeData()', () => {
|
||||
it('should set cmi.core.lesson_status to "completed"', () => {
|
||||
const scorm12API = api();
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import * as h from './api_helpers';
|
||||
import {scorm2004_error_codes} from '../src/constants/error_codes';
|
||||
import ErrorCodes from '../src/constants/error_codes';
|
||||
import Scorm2004API from '../src/Scorm2004API';
|
||||
import {scorm2004_values} from './field_values';
|
||||
|
||||
const api = () => {
|
||||
const scorm2004_error_codes = ErrorCodes.scorm2004;
|
||||
|
||||
const api = (startingData) => {
|
||||
const API = new Scorm2004API();
|
||||
API.apiLogLevel = 1;
|
||||
if (startingData) {
|
||||
API.startingData = startingData;
|
||||
}
|
||||
return API;
|
||||
};
|
||||
const apiInitialized = () => {
|
||||
const apiInitialized = (startingData) => {
|
||||
const API = api();
|
||||
if (startingData) {
|
||||
API.startingData = startingData;
|
||||
}
|
||||
API.lmsInitialize();
|
||||
return API;
|
||||
};
|
||||
@@ -288,6 +296,15 @@ 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',
|
||||
() => {
|
||||
const scorm2004API = apiInitialized();
|
||||
scorm2004API.setCMIValue('cmi.interactions.0.type', 'true-false');
|
||||
scorm2004API.setCMIValue('cmi.interactions.0.correct_responses.0.pattern', 'true');
|
||||
expect(
|
||||
String(scorm2004API.lmsGetLastError())
|
||||
).to.equal(String(0));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Initialized - Should Fail', () => {
|
||||
@@ -323,7 +340,7 @@ describe('SCORM 2004 API Tests', () => {
|
||||
scorm2004API.cmi.session_time = 'PT23H59M59S';
|
||||
const cmiExport = scorm2004API.renderCommitCMI(true);
|
||||
expect(
|
||||
cmiExport.cmi.total_time
|
||||
cmiExport.cmi.total_time,
|
||||
).to.equal('P1DT12H34M55S');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {describe, it} from 'mocha';
|
||||
import {aicc_constants} from '../../src/constants/api_constants';
|
||||
import {scorm12_error_codes} from '../../src/constants/error_codes';
|
||||
import APIConstants from '../../src/constants/api_constants';
|
||||
import ErrorCodes from '../../src/constants/error_codes';
|
||||
import {
|
||||
CMI,
|
||||
CMIEvaluationCommentsObject,
|
||||
@@ -15,6 +15,9 @@ import {
|
||||
import {expect} from 'chai';
|
||||
import {scorm12_values} from '../field_values';
|
||||
|
||||
const aicc_constants = APIConstants.aicc;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
||||
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
||||
const write_only = scorm12_error_codes.WRITE_ONLY_ELEMENT;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import {scorm12_constants} from '../../src/constants/api_constants';
|
||||
import {scorm12_error_codes} from '../../src/constants/error_codes';
|
||||
import APIConstants from '../../src/constants/api_constants';
|
||||
import ErrorCodes from '../../src/constants/error_codes';
|
||||
import {
|
||||
CMI,
|
||||
CMIInteractionsCorrectResponsesObject,
|
||||
@@ -12,6 +12,9 @@ import {
|
||||
import * as h from '../cmi_helpers';
|
||||
import {scorm12_values} from '../field_values';
|
||||
|
||||
const scorm12 = APIConstants.scorm12;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
||||
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
||||
const write_only = scorm12_error_codes.WRITE_ONLY_ELEMENT;
|
||||
@@ -101,7 +104,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi._children',
|
||||
expectedValue: scorm12_constants.cmi_children,
|
||||
expectedValue: scorm12.cmi_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkFieldConstraintSize({
|
||||
@@ -131,7 +134,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.core._children',
|
||||
expectedValue: scorm12_constants.core_children,
|
||||
expectedValue: scorm12.core_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadAndWrite({
|
||||
@@ -206,7 +209,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.core.score._children',
|
||||
expectedValue: scorm12_constants.score_children,
|
||||
expectedValue: scorm12.score_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkRead({
|
||||
@@ -247,7 +250,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.objectives._children',
|
||||
expectedValue: scorm12_constants.objectives_children,
|
||||
expectedValue: scorm12.objectives_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -263,7 +266,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.student_data._children',
|
||||
expectedValue: scorm12_constants.student_data_children,
|
||||
expectedValue: scorm12.student_data_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadAndWrite({
|
||||
@@ -285,7 +288,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.student_preference._children',
|
||||
expectedValue: scorm12_constants.student_preference_children,
|
||||
expectedValue: scorm12.student_preference_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkRead({
|
||||
@@ -333,7 +336,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.interactions._children',
|
||||
expectedValue: scorm12_constants.interactions_children,
|
||||
expectedValue: scorm12.interactions_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -357,7 +360,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi._children',
|
||||
expectedValue: scorm12_constants.cmi_children,
|
||||
expectedValue: scorm12.cmi_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkFieldConstraintSize({
|
||||
@@ -366,6 +369,11 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
limit: 4096,
|
||||
expectedError: type_mismatch,
|
||||
});
|
||||
h.checkWrite({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.suspend_data',
|
||||
valueToTest: '',
|
||||
});
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.launch_data',
|
||||
@@ -389,7 +397,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.core._children',
|
||||
expectedValue: scorm12_constants.core_children,
|
||||
expectedValue: scorm12.core_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -470,7 +478,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.core.score._children',
|
||||
expectedValue: scorm12_constants.score_children,
|
||||
expectedValue: scorm12.score_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkValidValues({
|
||||
@@ -498,7 +506,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.objectives._children',
|
||||
expectedValue: scorm12_constants.objectives_children,
|
||||
expectedValue: scorm12.objectives_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -514,7 +522,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.student_data._children',
|
||||
expectedValue: scorm12_constants.student_data_children,
|
||||
expectedValue: scorm12.student_data_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -539,7 +547,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.student_preference._children',
|
||||
expectedValue: scorm12_constants.student_preference_children,
|
||||
expectedValue: scorm12.student_preference_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkValidValues({
|
||||
@@ -573,7 +581,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.interactions._children',
|
||||
expectedValue: scorm12_constants.interactions_children,
|
||||
expectedValue: scorm12.interactions_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -768,7 +776,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: objective(),
|
||||
fieldName: 'cmi.score._children',
|
||||
expectedValue: scorm12_constants.score_children,
|
||||
expectedValue: scorm12.score_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkRead({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {describe, it} from 'mocha';
|
||||
import {scorm2004_error_codes} from '../../src/constants/error_codes';
|
||||
import {scorm2004_constants} from '../../src/constants/api_constants';
|
||||
import ErrorCodes from '../../src/constants/error_codes';
|
||||
import APIConstants from '../../src/constants/api_constants';
|
||||
import {
|
||||
ADL,
|
||||
CMI,
|
||||
@@ -14,6 +14,9 @@ import * as h from '../cmi_helpers';
|
||||
import {expect} from 'chai';
|
||||
import {scorm2004_values} from '../field_values';
|
||||
|
||||
const scorm2004_constants = APIConstants.scorm2004;
|
||||
const scorm2004_error_codes = ErrorCodes.scorm2004;
|
||||
|
||||
const read_only = scorm2004_error_codes.READ_ONLY_ELEMENT;
|
||||
const write_only = scorm2004_error_codes.WRITE_ONLY_ELEMENT;
|
||||
const type_mismatch = scorm2004_error_codes.TYPE_MISMATCH;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import * as Utilities from '../src/utilities';
|
||||
import {scorm12_regex, scorm2004_regex} from '../src/constants/regex';
|
||||
import Regex from '../src/constants/regex';
|
||||
|
||||
const scorm12_regex = Regex.scorm12;
|
||||
const scorm2004_regex = Regex.scorm2004;
|
||||
|
||||
describe('Utility Tests', () => {
|
||||
describe('getSecondsAsHHMMSS()', () => {
|
||||
|
||||
Reference in New Issue
Block a user