microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
7b48f26eb8caae7ed9cc1a09249195dfed76fa76

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

test/common/error/errorHelper.test.ts

61lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3import { ErrorHelper } from "../../../src/common/error/errorHelper";
4import { InternalErrorCode } from "../../../src/common/error/internalErrorCode";
5import assert = require("assert");
6
7suite("errorHelper", function () {
8 suite("commonContext", function () {
9 const internalErrorWithArgs = ErrorHelper.getInternalError(
10 InternalErrorCode.NotAllSuccessPatternsMatched,
11 "android",
12 "ios",
13 );
14 const internalErrorWithoutArgs = ErrorHelper.getInternalError(
15 InternalErrorCode.UnsupportedCommandStatus,
16 );
17 const nestedErrorWithArgs = ErrorHelper.getNestedError(
18 new Error("Nested ES Error"),
19 InternalErrorCode.CommandFailed,
20 "Command failed with ES Error",
21 );
22 const warning = ErrorHelper.getWarning("Warning");
23 const nestedWarning = ErrorHelper.getNestedWarning(new Error("Nested ES Error"), "Warning");
24
25 test("internal error object with arguments should have correct NotAllSuccessPatternsMatched error message on English", (done: Mocha.Done) => {
26 assert.strictEqual(
27 internalErrorWithArgs.message,
28 '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)',
29 );
30 done();
31 });
32
33 test("internal error object without arguments should have correct UnsupportedCommandStatus error message on English", (done: Mocha.Done) => {
34 assert.strictEqual(
35 internalErrorWithoutArgs.message,
36 "Unsupported command status (error code 112)",
37 );
38 done();
39 });
40
41 test("nested error object with arguments should have correct error message on English", (done: Mocha.Done) => {
42 assert.strictEqual(
43 nestedErrorWithArgs.message,
44 "Error while executing command 'Command failed with ES Error': Nested ES Error",
45 );
46 done();
47 });
48
49 test("warning object should have correct error message on English", (done: Mocha.Done) => {
50 assert.strictEqual(warning.errorCode, -1);
51 assert.strictEqual(warning.message, "Warning");
52 done();
53 });
54
55 test("nested warning object should have correct error message on English", (done: Mocha.Done) => {
56 assert.strictEqual(nestedWarning.errorCode, -1);
57 assert.strictEqual(nestedWarning.message, "Warning: Nested ES Error");
58 done();
59 });
60 });
61});
62