microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
cdef68eb3c8280164fd0195303fcd86976b058d8

Branches

Tags

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

Clone

HTTPS

Download ZIP

test/extension/exponent/exponentHelper.test.ts

59lines · 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
4import { ExponentHelper } from "../../../src/extension/exponent/exponentHelper";
5import * as path from "path";
6import * as assert from "assert";
7import * as sinon from "sinon";
8import { FileSystem } from "../../../src/common/node/fileSystem";
9
10suite("exponentHelper", function () {
11 const RESOURCES_ROOT = path.resolve(__dirname, "../../resources/exponentHelper");
12
13 async function checkIsExpoApp(packageJson: any, expected: boolean) {
14 let fs = new FileSystem();
15 sinon.stub(fs, "readFile", () => Promise.resolve(JSON.stringify(packageJson)));
16 const expoHelper = new ExponentHelper(RESOURCES_ROOT, "", fs);
17 const result = await expoHelper.isExpoApp(false);
18 assert.strictEqual(result, expected);
19 }
20
21 suite("extensionContext", () => {
22 suite("isExp", () => {
23 test("should return false if dependencies are empty", async () => {
24 await checkIsExpoApp({}, false);
25 });
26 test("should return false if (dev)dependencies.expo is missing", async () => {
27 await checkIsExpoApp({ dependencies: {} }, false);
28 await checkIsExpoApp({ devDependencies: {} }, false);
29 });
30 test("should return false if dependencies.react-native is missing or incorrect", async () => {
31 await checkIsExpoApp({ dependencies: {} }, false);
32 await checkIsExpoApp({ dependencies: { "react-native": "" } }, false);
33 await checkIsExpoApp({ dependencies: { "react-native": "0.58.8" } }, false);
34 });
35 test("should return true if (dev)dependencies.expo exists and dependencies.react-native is correct", async () => {
36 await checkIsExpoApp(
37 {
38 dependencies: {
39 expo: "33.0.1",
40 "react-native":
41 "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
42 },
43 },
44 true,
45 );
46 await checkIsExpoApp(
47 {
48 devDependencies: { expo: "33.0.1" },
49 dependencies: {
50 "react-native":
51 "https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz",
52 },
53 },
54 true,
55 );
56 });
57 });
58 });
59});
60