Initial API tests

This commit is contained in:
Jonathan Putney
2019-11-13 23:07:28 -05:00
parent ed57b705b1
commit 6dc512ba1f
8 changed files with 136 additions and 75 deletions

18
test/api_helpers.js Normal file
View File

@@ -0,0 +1,18 @@
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));
});
});
};