2018-03-07 22:50:48 +01:00
|
|
|
/**
|
|
|
|
* Tests for the ErrorCodes objects in error_codes.js generated file.
|
|
|
|
*/
|
|
|
|
const tests = [];
|
|
|
|
|
|
|
|
const nonExistingErrorCode = 999999999;
|
|
|
|
|
|
|
|
tests.push(function errorCodesShouldThrowExceptionForNonExistingError() {
|
|
|
|
assert.throws(() => {
|
|
|
|
return ErrorCodes.thisIsAnErrorCodeThatDoesNotExist;
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-03-07 22:50:48 +01:00
|
|
|
|
|
|
|
tests.push(function errorCodesShouldNotThrowExceptionForExistingError() {
|
|
|
|
assert.doesNotThrow(() => {
|
|
|
|
return ErrorCodes.BadValue;
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-03-07 22:50:48 +01:00
|
|
|
|
2018-04-27 15:24:01 +02:00
|
|
|
tests.push(function errorCodesShouldNotThrowExceptionForInheritedAttributes() {
|
|
|
|
assert.doesNotThrow(() => {
|
|
|
|
return ErrorCodes.prototype;
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-04-27 15:24:01 +02:00
|
|
|
|
|
|
|
tests.push(function errorCodesShouldNotThrowExceptionForSymbols() {
|
|
|
|
assert.doesNotThrow(() => {
|
|
|
|
return print(+ErrorCodes);
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-04-27 15:24:01 +02:00
|
|
|
|
|
|
|
tests.push(function errorCodesShouldNotThrowExceptionForConstructor() {
|
|
|
|
assert.doesNotThrow(() => {
|
|
|
|
return ErrorCodes.constructor;
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-04-27 15:24:01 +02:00
|
|
|
|
2018-03-07 22:50:48 +01:00
|
|
|
tests.push(function errorCodeStringsShouldThrowExceptionForNonExistingError() {
|
|
|
|
assert.throws(() => {
|
|
|
|
return ErrorCodeStrings[nonExistingErrorCode];
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-03-07 22:50:48 +01:00
|
|
|
|
|
|
|
tests.push(function errorCodeStringsShouldNotThrowExceptionForExistingError() {
|
|
|
|
assert.doesNotThrow(() => {
|
|
|
|
return ErrorCodeStrings[2];
|
|
|
|
});
|
2023-07-07 00:43:46 +02:00
|
|
|
});
|
2018-03-07 22:50:48 +01:00
|
|
|
|
|
|
|
tests.push(function errorCodesShouldHaveCategoriesDefined() {
|
|
|
|
assert.eq(true, ErrorCodes.isNetworkError(ErrorCodes.HostNotFound));
|
|
|
|
});
|
|
|
|
|
|
|
|
tests.push(function errorCodesCategoriesShouldReturnFalseOnNonExistingErrorCodes() {
|
|
|
|
assert.eq(false, ErrorCodes.isNetworkError(nonExistingErrorCode));
|
|
|
|
});
|
|
|
|
|
|
|
|
/* main */
|
|
|
|
tests.forEach((test) => {
|
|
|
|
jsTest.log(`Starting tests '${test.name}'`);
|
|
|
|
test();
|
|
|
|
});
|