Throw message for ValidationExceptions
This commit is contained in:
@@ -45,7 +45,7 @@ export const checkLMSSetValue = (
|
||||
if (expectedError > 0) {
|
||||
if (errorThrown) {
|
||||
expect(() => api.lmsSetValue(fieldName, valueToTest)).
|
||||
to.throw(String(expectedError));
|
||||
to.throw().with.property('errorCode', expectedError);
|
||||
} else {
|
||||
api.lmsSetValue(fieldName, valueToTest);
|
||||
expect(String(api.lmsGetLastError())).to.equal(String(expectedError));
|
||||
@@ -84,7 +84,7 @@ export const checkLMSGetValue = (
|
||||
if (expectedError > 0) {
|
||||
if (errorThrown) {
|
||||
expect(() => api.lmsGetValue(fieldName)).
|
||||
to.throw(String(expectedError));
|
||||
to.throw().with.property('errorCode', expectedError);
|
||||
} else {
|
||||
api.lmsGetValue(fieldName);
|
||||
expect(String(api.lmsGetLastError())).to.equal(String(expectedError));
|
||||
@@ -110,7 +110,7 @@ export const checkSetCMIValue = (
|
||||
if (expectedError > 0) {
|
||||
if (errorThrown) {
|
||||
expect(() => api.setCMIValue(fieldName, valueToTest)).
|
||||
to.throw(String(expectedError));
|
||||
to.throw().with.property('errorCode', expectedError);
|
||||
} else {
|
||||
api.setCMIValue(fieldName, valueToTest);
|
||||
expect(String(api.lmsGetLastError())).to.equal(String(expectedError));
|
||||
|
||||
@@ -23,7 +23,7 @@ export const checkFieldConstraintSize = (
|
||||
it(`Should fail to write more than ${limit} characters to ${fieldName}`,
|
||||
() => {
|
||||
expect(() => eval(`${fieldName} = 'x'.repeat(${limit + 1})`)).
|
||||
to.throw(expectedError + '');
|
||||
to.throw().with.property('errorCode', expectedError);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -42,7 +42,7 @@ export const checkReadOnly = (
|
||||
|
||||
it(`Should fail to write to ${fieldName}`, () => {
|
||||
expect(() => eval(`${fieldName} = 'xxx'`)).
|
||||
to.throw(expectedError + '');
|
||||
to.throw().with.property('errorCode', expectedError);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -89,7 +89,7 @@ export const checkWriteOnly = (
|
||||
describe(`Field: ${fieldName}`, () => {
|
||||
it(`Should fail to read from ${fieldName}`, () => {
|
||||
expect(() => eval(`${fieldName}`)).
|
||||
to.throw(expectedError + '');
|
||||
to.throw().with.property('errorCode', expectedError);
|
||||
});
|
||||
|
||||
it(`Should successfully write to ${fieldName}`, () => {
|
||||
|
||||
@@ -5,12 +5,12 @@ import {ValidationError} from '../src/exceptions';
|
||||
describe('Exception Tests', () => {
|
||||
it('ValidationException should return message string', () => {
|
||||
expect(
|
||||
new ValidationError(0).message,
|
||||
).to.equal('0');
|
||||
new ValidationError(0, 'Error Message').message,
|
||||
).to.equal('Error Message');
|
||||
});
|
||||
it('ValidationException should return errorCode number', () => {
|
||||
expect(
|
||||
new ValidationError(0).errorCode,
|
||||
new ValidationError(0, 'Error Message').errorCode,
|
||||
).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user