Files
scorm-again/test/api_helpers.js
Jonathan Putney 6dc512ba1f Initial API tests
2019-11-13 23:07:28 -05:00

19 lines
513 B
JavaScript

import {describe, it} from 'mocha';
import {expect} from 'chai';
export const checkWrite = (
{
api,
fieldName,
valueToTest = 'xxx',
expectedError = 0,
}) => {
describe(`Field: ${fieldName}`, () => {
const status = expectedError > 0 ? 'fail to' : 'successfully';
it(`Should ${status} write to ${fieldName}`, () => {
eval(`api.lmsSetValue('${fieldName}', '${valueToTest}')`);
expect(String(api.lastErrorCode)).to.equal(String(expectedError));
});
});
};