Handling non-string values being passed to SetValue/LMSSetValue

This commit is contained in:
Jonathan Putney
2019-12-30 11:33:08 -05:00
parent 7b780c4c39
commit a1d94eef97
5 changed files with 90 additions and 2 deletions

View File

@@ -1,6 +1,36 @@
import {describe, it} from 'mocha';
import {expect} from 'chai';
export const checkValidValues = (
{
api,
fieldName,
validValues,
invalidValues,
}) => {
describe(`Field: ${fieldName}`, () => {
for (const idx in validValues) {
if ({}.hasOwnProperty.call(validValues, idx)) {
it(`Should successfully write '${validValues[idx]}' to ${fieldName}`,
() => {
expect(api.lmsSetValue(fieldName, validValues[idx])).
to.equal('true');
});
}
}
for (const idx in invalidValues) {
if ({}.hasOwnProperty.call(invalidValues, idx)) {
it(`Should fail to write '${invalidValues[idx]}' to ${fieldName}`,
() => {
expect(api.lmsSetValue(fieldName, invalidValues[idx])).
to.equal('false');
});
}
}
});
};
export const checkLMSSetValue = (
{
api,