microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
e50dadc05b664d9b6f5bac64bbc5739db07304cf

Branches

Tags

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

Clone

HTTPS

Download ZIP

test/extension/exponent/exponentHelper.test.ts

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