microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
test/common/error/errorHelper.test.ts
43lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
| 3 | import { ErrorHelper } from "../../../src/common/error/errorHelper"; |
| 4 | import { InternalErrorCode } from "../../../src/common/error/internalErrorCode"; |
| 5 | import * as assert from "assert"; |
| 6 | |
| 7 | suite("errorHelper", function() { |
| 8 | suite("commonContext", function() { |
| 9 | const internalErrorWithArgs = ErrorHelper.getInternalError(InternalErrorCode.NotAllSuccessPatternsMatched, "android", "ios"); |
| 10 | const internalErrorWithoutArgs = ErrorHelper.getInternalError(InternalErrorCode.UnsupportedCommandStatus); |
| 11 | const nestedErrorWithArgs = ErrorHelper.getNestedError(new Error("Nested ES Error"), InternalErrorCode.CommandFailed, "Command failed with ES Error"); |
| 12 | const warning = ErrorHelper.getWarning("Warning"); |
| 13 | const nestedWarning = ErrorHelper.getNestedWarning(new Error("Nested ES Error"), "Warning"); |
| 14 | |
| 15 | test("internal error object with arguments should have correct NotAllSuccessPatternsMatched error message on English", (done: MochaDone) => { |
| 16 | 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)"); |
| 17 | done(); |
| 18 | }); |
| 19 | |
| 20 | test("internal error object without arguments should have correct UnsupportedCommandStatus error message on English", (done: MochaDone) => { |
| 21 | assert.equal(internalErrorWithoutArgs.message, "Unsupported command status (error code 112)"); |
| 22 | done(); |
| 23 | }); |
| 24 | |
| 25 | test("nested error object with arguments should have correct error message on English", (done: MochaDone) => { |
| 26 | assert.equal(nestedErrorWithArgs.message, "Error while executing command 'Command failed with ES Error': Nested ES Error"); |
| 27 | done(); |
| 28 | }); |
| 29 | |
| 30 | test("warning object should have correct error message on English", (done: MochaDone) => { |
| 31 | assert.equal(warning.errorCode, -1); |
| 32 | assert.equal(warning.message, "Warning"); |
| 33 | done(); |
| 34 | }); |
| 35 | |
| 36 | test("nested warning object should have correct error message on English", (done: MochaDone) => { |
| 37 | assert.equal(nestedWarning.errorCode, -1); |
| 38 | assert.equal(nestedWarning.message, "Warning: Nested ES Error"); |
| 39 | done(); |
| 40 | }); |
| 41 | |
| 42 | }); |
| 43 | }); |
| 44 | |