microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
test/extension/ios/iOSPlatform.test.ts
69lines · 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 | |
| 4 | import assert = require("assert"); |
| 5 | import * as sinon from "sinon"; |
| 6 | |
| 7 | import { IOSPlatform } from "../../../src/extension/ios/iOSPlatform"; |
| 8 | |
| 9 | import "should"; |
| 10 | import { SettingsHelper } from "../../../src/extension/settingsHelper"; |
| 11 | import { PlatformType } from "../../../src/extension/launchArgs"; |
| 12 | |
| 13 | suite("iOSPlatform", function () { |
| 14 | const workspaceRoot: string = "/User/test/react-native/AwesomeProject"; |
| 15 | const projectRoot = "/User/test/react-native/AwesomeProject"; |
| 16 | const nodeModulesRoot: string = projectRoot; |
| 17 | |
| 18 | let runOptions: any = { |
| 19 | platform: PlatformType.iOS, |
| 20 | workspaceRoot, |
| 21 | projectRoot, |
| 22 | nodeModulesRoot, |
| 23 | }; |
| 24 | |
| 25 | let getReactNativeProjectRootStub: Sinon.SinonStub; |
| 26 | |
| 27 | setup(() => { |
| 28 | getReactNativeProjectRootStub = sinon.stub( |
| 29 | SettingsHelper, |
| 30 | "getReactNativeProjectRoot", |
| 31 | () => projectRoot, |
| 32 | ); |
| 33 | }); |
| 34 | |
| 35 | teardown(() => { |
| 36 | runOptions = { |
| 37 | platform: PlatformType.iOS, |
| 38 | workspaceRoot, |
| 39 | projectRoot, |
| 40 | nodeModulesRoot, |
| 41 | }; |
| 42 | getReactNativeProjectRootStub.restore(); |
| 43 | }); |
| 44 | |
| 45 | suite("extensionContext", function () { |
| 46 | test("getRunArgument properties not defined", function () { |
| 47 | let platform = new IOSPlatform(runOptions); |
| 48 | assert.deepEqual(platform.runArguments, []); |
| 49 | }); |
| 50 | test("getRunArgument simulator simulator", function () { |
| 51 | runOptions.target = "simulator"; |
| 52 | const expected = ["--simulator"]; |
| 53 | let platform = new IOSPlatform(runOptions); |
| 54 | assert.deepEqual(platform.runArguments, expected); |
| 55 | }); |
| 56 | test("getRunArgument device device", function () { |
| 57 | runOptions.target = "device"; |
| 58 | const expected = ["--device"]; |
| 59 | let platform = new IOSPlatform(runOptions); |
| 60 | assert.deepEqual(platform.runArguments, expected); |
| 61 | }); |
| 62 | test("getRunArgument target device id", function () { |
| 63 | runOptions.target = "925E6E38-0D7B-45E9-ADE0-89C20779D467"; |
| 64 | const expected = ["--udid", runOptions.target]; |
| 65 | let platform = new IOSPlatform(runOptions); |
| 66 | assert.deepEqual(platform.runArguments, expected); |
| 67 | }); |
| 68 | }); |
| 69 | }); |
| 70 | |