Add tests for errorHelper.ts, fix messages for warnings, fix gulp task build asynchronicity (#862)

This commit is contained in:
Yuri Skorokhodov 2018-12-14 15:59:52 +03:00 коммит произвёл GitHub
Родитель 10f9b91495
Коммит e416b90106
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 29 добавлений и 5 удалений

Просмотреть файл

@ -133,13 +133,17 @@ gulp.task("tslint", function () {
// We should also make sure that we always generate urls in all the path properties (We shouldn"t have \\s. This seems to
// be an issue on Windows platforms)
gulp.task("build", gulp.series("check-imports", "check-copyright", "tslint", function (done) {
build(true, true);
done();
build(true, true)
.once("finish", () => {
done();
});
}));
gulp.task("build-dev", gulp.series("check-imports", "check-copyright", function (done) {
build(false, false);
done();
build(false, false)
.once("finish", () => {
done();
});
}));
gulp.task("quick-build", gulp.series("build-dev"));

Просмотреть файл

@ -20,6 +20,7 @@ export class ErrorHelper {
public static wrapError(error: InternalError, innerError: Error): NestedError {
return NestedError.getWrappedError(error, innerError);
}
public static getWarning(message: string, ...optionalArgs: any[]): InternalError {
return new InternalError(-1, message, InternalErrorLevel.Warning);
}

Просмотреть файл

@ -18,7 +18,7 @@ export class InternalError extends Error {
super(message);
this.errorCode = errorCode;
this.errorLevel = errorLevel;
this.message = message + ` (error code ${this.errorCode})`;
this.message = errorCode > 0 ? (message + ` (error code ${this.errorCode})`) : message;
}
}

Просмотреть файл

@ -8,6 +8,9 @@ suite("errorHelper", function() {
suite("commonContext", function() {
const internalErrorWithArgs = ErrorHelper.getInternalError(InternalErrorCode.NotAllSuccessPatternsMatched, "android", "ios");
const internalErrorWithoutArgs = ErrorHelper.getInternalError(InternalErrorCode.UnsupportedCommandStatus);
const nestedErrorWithArgs = ErrorHelper.getNestedError(new Error("Nested ES Error"), InternalErrorCode.CommandFailed, "Command failed with ES Error");
const warning = ErrorHelper.getWarning("Warning");
const nestedWarning = ErrorHelper.getNestedWarning(new Error("Nested ES Error"), "Warning");
test("internal error object with arguments should have correct NotAllSuccessPatternsMatched error message on English", (done: MochaDone) => {
assert.equal(internalErrorWithArgs.message, "Unknown error: not all success patterns were matched. \n It means that \"react-native run-android\" command failed. \n Please, check the View -> Toggle Output -> React Native, \n View -> Toggle Output -> React Native: Run ios output windows. (error code 712)");
@ -19,6 +22,22 @@ suite("errorHelper", function() {
done();
});
test("nested error object with arguments should have correct error message on English", (done: MochaDone) => {
assert.equal(nestedErrorWithArgs.message, "Error while executing command 'Command failed with ES Error': Nested ES Error");
done();
});
test("warning object should have correct error message on English", (done: MochaDone) => {
assert.equal(warning.errorCode, -1);
assert.equal(warning.message, "Warning");
done();
});
test("nested warning object should have correct error message on English", (done: MochaDone) => {
assert.equal(nestedWarning.errorCode, -1);
assert.equal(nestedWarning.message, "Warning: Nested ES Error");
done();
});
});
});