Moving field values to test src

This commit is contained in:
Jonathan Putney
2020-01-09 09:36:08 -05:00
parent 8d8831954e
commit d460053cbb
10 changed files with 29 additions and 32 deletions

View File

@@ -3,7 +3,7 @@ import {describe, it} from 'mocha';
import * as h from './api_helpers';
import {scorm2004_error_codes} from '../src/constants/error_codes';
import Scorm2004API from '../src/Scorm2004API';
import {scorm2004_values} from '../src/constants/field_values';
import {scorm2004_values} from './field_values';
const api = () => {
const API = new Scorm2004API();

View File

@@ -13,7 +13,7 @@ import {
NAV,
} from '../../src/cmi/scorm12_cmi';
import {expect} from 'chai';
import {scorm12_values} from '../../src/constants/field_values';
import {scorm12_values} from '../field_values';
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
@@ -520,7 +520,7 @@ describe('AICC CMI Tests', () => {
).
to.
equal(
'{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"not attempted","entry":"","total_time":"","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":"","tries":{"0":{"status":"","time":"","score":{"raw":"","min":"","max":"100"}}}},"student_preference":{"audio":"","language":"","speed":"","text":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}},"evaluation":{"comments":{"0":{"content":"","location":"","time":""}}}}');
'{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"not attempted","entry":"","total_time":"00:00:00","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":"","tries":{"0":{"status":"","time":"","score":{"raw":"","min":"","max":"100"}}}},"student_preference":{"audio":"","language":"","speed":"","text":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}},"evaluation":{"comments":{"0":{"content":"","location":"","time":""}}}}');
});
});

View File

@@ -10,7 +10,7 @@ import {
CMIObjectivesObject,
} from '../../src/cmi/scorm12_cmi';
import * as h from '../cmi_helpers';
import {scorm12_values} from '../../src/constants/field_values';
import {scorm12_values} from '../field_values';
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
@@ -592,7 +592,7 @@ describe('SCORM 1.2 CMI Tests', () => {
).
to.
equal(
'{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"not attempted","entry":"","total_time":"","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":""},"student_preference":{"audio":"","language":"","speed":"","text":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}}}');
'{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"not attempted","entry":"","total_time":"00:00:00","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":""},"student_preference":{"audio":"","language":"","speed":"","text":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}}}');
});
});

View File

@@ -12,7 +12,7 @@ import {
} from '../../src/cmi/scorm2004_cmi';
import * as h from '../cmi_helpers';
import {expect} from 'chai';
import {scorm2004_values} from '../../src/constants/field_values';
import {scorm2004_values} from '../field_values';
const read_only = scorm2004_error_codes.READ_ONLY_ELEMENT;
const write_only = scorm2004_error_codes.WRITE_ONLY_ELEMENT;
@@ -234,7 +234,7 @@ describe('SCORM 2004 CMI Tests', () => {
h.checkReadAndWrite({
cmi: cmi(),
fieldName: 'cmi.total_time',
expectedValue: '0',
expectedValue: '',
});
/**
@@ -402,7 +402,7 @@ describe('SCORM 2004 CMI Tests', () => {
).
to.
equal(
'{"comments_from_learner":{},"comments_from_lms":{},"completion_status":"unknown","completion_threshold":"","credit":"credit","entry":"","exit":"","interactions":{"0":{"id":"","type":"","objectives":{},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{}}},"launch_data":"","learner_id":"","learner_name":"","learner_preference":{"audio_level":"1","language":"","delivery_speed":"1","audio_captioning":"0"},"location":"","max_time_allowed":"","mode":"normal","objectives":{"0":{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}},"progress_measure":"","scaled_passing_score":"","score":{"scaled":"","raw":"","min":"","max":""},"session_time":"PT0H0M0S","success_status":"unknown","suspend_data":"","time_limit_action":"continue,no message","total_time":"0"}');
'{"comments_from_learner":{},"comments_from_lms":{},"completion_status":"unknown","completion_threshold":"","credit":"credit","entry":"","exit":"","interactions":{"0":{"id":"","type":"","objectives":{},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{}}},"launch_data":"","learner_id":"","learner_name":"","learner_preference":{"audio_level":"1","language":"","delivery_speed":"1","audio_captioning":"0"},"location":"","max_time_allowed":"","mode":"normal","objectives":{"0":{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}},"progress_measure":"","scaled_passing_score":"","score":{"scaled":"","raw":"","min":"","max":""},"session_time":"PT0H0M0S","success_status":"unknown","suspend_data":"","time_limit_action":"continue,no message","total_time":"PT0S"}');
});
});
@@ -543,7 +543,7 @@ describe('SCORM 2004 CMI Tests', () => {
h.checkReadOnly({
cmi: cmiInitialized(),
fieldName: 'cmi.total_time',
expectedValue: '0',
expectedValue: '',
expectedError: read_only,
});
@@ -712,7 +712,7 @@ describe('SCORM 2004 CMI Tests', () => {
).
to.
equal(
'{"comments_from_learner":{},"comments_from_lms":{},"completion_status":"unknown","completion_threshold":"","credit":"credit","entry":"","exit":"","interactions":{"0":{"id":"","type":"","objectives":{},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{}}},"launch_data":"","learner_id":"","learner_name":"","learner_preference":{"audio_level":"1","language":"","delivery_speed":"1","audio_captioning":"0"},"location":"","max_time_allowed":"","mode":"normal","objectives":{"0":{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}},"progress_measure":"","scaled_passing_score":"","score":{"scaled":"","raw":"","min":"","max":""},"session_time":"PT0H0M0S","success_status":"unknown","suspend_data":"","time_limit_action":"continue,no message","total_time":"0"}');
'{"comments_from_learner":{},"comments_from_lms":{},"completion_status":"unknown","completion_threshold":"","credit":"credit","entry":"","exit":"","interactions":{"0":{"id":"","type":"","objectives":{},"timestamp":"","weighting":"","learner_response":"","result":"","latency":"","description":"","correct_responses":{}}},"launch_data":"","learner_id":"","learner_name":"","learner_preference":{"audio_level":"1","language":"","delivery_speed":"1","audio_captioning":"0"},"location":"","max_time_allowed":"","mode":"normal","objectives":{"0":{"id":"","success_status":"unknown","completion_status":"unknown","progress_measure":"","description":"","score":{"scaled":"","raw":"","min":"","max":""}}},"progress_measure":"","scaled_passing_score":"","score":{"scaled":"","raw":"","min":"","max":""},"session_time":"PT0H0M0S","success_status":"unknown","suspend_data":"","time_limit_action":"continue,no message","total_time":"PT0S"}');
});
});

334
test/field_values.js Normal file
View File

@@ -0,0 +1,334 @@
const common_values = {
validResult: [
'correct',
'wrong',
'unanticipated',
'neutral',
],
invalidResult: [
'-10000',
'10000',
'invalid',
],
valid0To1Range: [
'0.0',
'0.25',
'0.5',
'1.0',
],
invalid0To1Range: [
'-1',
'-0.1',
'1.1',
'.25',
],
valid0To100Range: [
'1',
'50',
'100',
],
invalid0To100Range: [
'invalid',
'a100',
'-1',
],
validScaledRange: [
'1',
'0.5',
'0',
'-0.5',
'-1',
],
invalidScaledRange: [
'-101',
'25.1',
'50.5',
'75',
'100',
],
validIntegerScaledRange: [
'1',
'0',
'-1',
],
invalidIntegerScaledRange: [
'-101',
'-0.5',
'0.5',
'25.1',
'50.5',
'75',
'100',
],
};
export const scorm12_values = {
...common_values, ...{
validLessonStatus: [
'passed',
'completed',
'failed',
'incomplete',
'browsed',
],
invalidLessonStatus: [
'Passed',
'P',
'F',
'p',
'true',
'false',
'complete',
],
validExit: [
'time-out',
'suspend',
'logout',
],
invalidExit: [
'close',
'exit',
'crash',
],
validType: [
'true-false',
'choice',
'fill-in',
'matching',
'performance',
'sequencing',
'likert',
'numeric',
],
invalidType: [
'correct',
'wrong',
'logout',
],
validSpeedRange: [
'1',
'50',
'100',
'-1',
'-50',
'-100',
],
invalidSpeedRange: [
'invalid',
'a100',
'-101',
'101',
'-100000',
'100000',
],
validScoreRange: [
'1',
'50.25',
'100',
],
invalidScoreRange: [
'invalid',
'a100',
'-1',
'101',
'-100000',
'100000',
],
invalid0To100Range: [
'invalid',
'a100',
'-2',
],
validTime: [
'10:06:57',
'23:59:59',
'00:00:00',
],
invalidTime: [
'47:59:59',
'00:00:01.56',
'06:5:13',
'23:59:59.123',
'P1DT23H59M59S',
],
validTimespan: [
'10:06:57',
'00:00:01.56',
'23:59:59',
'47:59:59',
],
invalidTimespan: [
'06:5:13',
'23:59:59.123',
'P1DT23H59M59S',
],
},
};
export const scorm2004_values = {
...common_values, ...{
// valid field values
validTimestamps: [
'2019-06-25',
'2019-06-25T23:59',
'2019-06-25T23:59:59.99',
'1970-01-01',
],
invalidTimestamps: [
'2019-06-25T',
'2019-06-25T23:59:59.999',
'2019-06-25T25:59:59.99',
'2019-13-31',
'1969-12-31',
'-00:00:30',
'0:50:30',
'23:00:30.',
],
validCStatus: [
'completed',
'incomplete',
'not attempted',
'unknown',
],
invalidCStatus: [
'complete',
'passed',
'failed',
],
validSStatus: [
'passed',
'failed',
'unknown',
],
invalidSStatus: [
'complete',
'incomplete',
'P',
'f',
],
validExit: [
'time-out',
'suspend',
'logout',
'normal',
],
invalidExit: [
'close',
'exit',
'crash',
],
validType: [
'true-false',
'choice',
'fill-in',
'long-fill-in',
'matching',
'performance',
'sequencing',
'likert',
'numeric',
'other',
],
invalidType: [
'correct',
'wrong',
'logout',
],
validScoreRange: [
'1',
'50',
'100',
'-10000',
'-1',
'10000',
],
invalidScoreRange: [
'invalid',
'a100',
'-100000',
'100000',
],
validISO8601Durations: [
'P1Y34DT23H45M15S',
'PT1M45S',
'P0S',
'PT75M',
],
invalidISO8601Durations: [
'00:08:45',
'-P1H',
'1y45D',
'0',
],
validComment: [
'{lang=en-98} learner comment',
'{lang=eng-98-9} learner comment',
'{lang=eng-98-9fhgj}' + 'x'.repeat(4000),
'learner comment',
'learner comment}',
'{lang=i-xx}',
'{lang=i}',
'',
],
invalidComment: [
'{lang=i-}',
'{lang=i-x}',
'{lang=eng-98-9fhgj}{ learner comment',
'{learner comment',
'{lang=eng-98-9fhgj}' + 'x'.repeat(4001),
'{lang=eng-98-9fhgj}{' + 'x'.repeat(3999),
],
validDescription: [
'{lang=en-98} learner comment',
'{lang=eng-98-9} learner comment',
'{lang=eng-98-9fhgj}' + 'x'.repeat(250),
'learner comment',
'learner comment}',
'{lang=i-xx}',
'{lang=i}',
'',
],
invalidDescription: [
'{lang=i-}',
'{lang=i-x}',
'{lang=eng-98-9fhgj}{ learner comment',
'{learner comment',
'{lang=eng-98-9fhgj}' + 'x'.repeat(251),
'{lang=eng-98-9fhgj}{' + 'x'.repeat(249),
],
validNavRequest: [
'previous',
'continue',
'exit',
'exitAll',
'abandon',
'abandonAll',
'suspendAll',
],
invalidNavRequest: [
'close',
'quit',
'next',
'before',
],
},
};