Working on the saving of data

This commit is contained in:
Jonathan Putney
2019-11-15 17:24:30 -05:00
parent 51da89f737
commit 8e6f6c47e9
11 changed files with 559 additions and 75 deletions

View File

@@ -274,4 +274,60 @@ describe('Utility Tests', () => {
).to.equal('01:05:30.5');
});
});
describe('flatten()', () => {
it('Should return flattened object', () => {
expect(
Utilities.flatten({
'cmi': {
'core': {
'learner_id': 'jputney',
'learner_name': 'Jonathan',
},
'objectives': {
'0': {
'id': 'AAA',
},
'1': {
'id': 'BBB',
},
},
},
}),
).to.eql({
'cmi.core.learner_id': 'jputney',
'cmi.core.learner_name': 'Jonathan',
'cmi.objectives.0.id': 'AAA',
'cmi.objectives.1.id': 'BBB',
});
});
});
describe('unflatten()', () => {
it('Should return flattened object', () => {
expect(
Utilities.unflatten({
'cmi.core.learner_id': 'jputney',
'cmi.core.learner_name': 'Jonathan',
'cmi.objectives.0.id': 'AAA',
'cmi.objectives.1.id': 'BBB',
}),
).to.eql({
'cmi': {
'core': {
'learner_id': 'jputney',
'learner_name': 'Jonathan',
},
'objectives': {
'0': {
'id': 'AAA',
},
'1': {
'id': 'BBB',
},
},
},
});
});
});
});