Add more tests for ErrorHelper class, add more error messages for error codes (#861)

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

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

@ -45,5 +45,6 @@ export const ERROR_STRINGS = {
[InternalErrorCode.NotAllSuccessPatternsMatched]: localize("NotAllSuccessPatternsMatched", "Unknown error: not all success patterns were matched. \n It means that \"react-native run-{0}\" command failed. \n Please, check the View -> Toggle Output -> React Native, \n View -> Toggle Output -> React Native: Run {1} output windows."),
[InternalErrorCode.CouldNotParsePackageVersion]: localize("CouldNotParsePackageVersion", "Couldn't parse the version component of the package at {0}: version = {1}"),
[InternalErrorCode.UnsupportedCommandStatus]: localize("UnsupportedCommandStatus", "Unsupported command status"),
[InternalErrorCode.ExpectedExponentTunnelPath]: localize("ExpectedExponentTunnelPath", "No link provided by exponent. Is your project correctly setup?"),
[InternalErrorCode.WorkspaceNotFound]: localize("WorkspaceNotFound", "Error while working with workspace: {0}"),
};

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

@ -82,8 +82,7 @@ export class ExponentPlatform extends GeneralMobilePlatform {
})
.then(exponentUrl => {
if (!exponentUrl) {
return Q.reject<void>(ErrorHelper.getInternalError(InternalErrorCode.ExpectedExponentTunnelPath,
"No link provided by exponent. Is your project correctly setup?"));
return Q.reject<void>(ErrorHelper.getInternalError(InternalErrorCode.ExpectedExponentTunnelPath));
}
this.exponentTunnelPath = exponentUrl;
const outputMessage = `Application is running on Exponent. Open your exponent app at ${this.exponentTunnelPath} to see it.`;

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

@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
import { ErrorHelper } from "../../../src/common/error/errorHelper";
import { InternalErrorCode } from "../../../src/common/error/internalErrorCode";
import * as assert from "assert";
suite("errorHelper", function() {
suite("commonContext", function() {
const internalErrorWithArgs = ErrorHelper.getInternalError(InternalErrorCode.NotAllSuccessPatternsMatched, "android", "ios");
const internalErrorWithoutArgs = ErrorHelper.getInternalError(InternalErrorCode.UnsupportedCommandStatus);
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)");
done();
});
test("internal error object without arguments should have correct UnsupportedCommandStatus error message on English", (done: MochaDone) => {
assert.equal(internalErrorWithoutArgs.message, "Unsupported command status (error code 112)");
done();
});
});
});