microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.9

Branches

Tags

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

Clone

HTTPS

Download ZIP

test/extension/ios/xcodeproj.test.ts

60lines · 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 {Xcodeproj} from "../../../src/extension/ios/xcodeproj";
5
6import * as assert from "assert";
7import * as path from "path";
8import * as Q from "q";
9
10suite("xcodeproj", function() {
11 suite("extensionContext", function() {
12 test("should look in the correct location for xcodeproj files and return one", function() {
13 const projectRoot = path.join("/", "tmp", "myProject");
14 const projectName = "foo";
15 const fileType = ".xcodeproj";
16 const testFiles = [projectName + fileType];
17 const mockFileSystem: any = {
18 readDir: () => {
19 return Q(testFiles);
20 },
21 };
22
23 const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
24
25 return xcodeproj.findXcodeprojFile(projectRoot)
26 .then((proj) => {
27 assert.deepEqual(proj, {
28 fileName: path.join(projectRoot, testFiles[0]),
29 fileType,
30 projectName,
31 });
32 });
33 });
34 test("should look in the correct location for xcodeproj/xcworkspace files and prefer xcworkspace over xcodeproj", function() {
35 const projectRoot = path.join("/", "tmp", "myProject");
36 const projectName = "foo";
37 const xcodeprojFileType = ".xcodeproj";
38 const xcworkspaceFileType = ".xcworkspace";
39 const xcodeprojFileName = projectName + xcodeprojFileType;
40 const xcworkspaceFileName = projectName + xcworkspaceFileType;
41 const testFiles = [xcodeprojFileName, xcworkspaceFileName];
42 const mockFileSystem: any = {
43 readDir: () => {
44 return Q(testFiles);
45 },
46 };
47
48 const xcodeproj = new Xcodeproj({ nodeFileSystem: mockFileSystem });
49
50 return xcodeproj.findXcodeprojFile(projectRoot)
51 .then((proj) => {
52 assert.deepEqual(proj, {
53 fileName: path.join(projectRoot, xcworkspaceFileName),
54 fileType: xcworkspaceFileType,
55 projectName,
56 });
57 });
58 });
59 });
60});
61