microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
db80cd4e10b83524bc77c15018effab72cbabeb8

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/test/common/ios/plistBuddy.test.ts

40lines · 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 {PlistBuddy} from "../../../common/ios/plistBuddy";
5
6import * as Q from "q";
7import * as sinon from "sinon";
8
9suite("plistBuddy", function() {
10 suite("commonContext", function() {
11 test("should attempt to modify, then add, plist properties", function() {
12 const plistFileName = "testFile.plist";
13 const plistProperty = "myProperty";
14 const plistValue = "myValue";
15
16 const mockedExecFunc = sinon.stub();
17 mockedExecFunc.onFirstCall().returns({ outcome: Q.reject(new Error("Setting does not exist")) });
18 mockedExecFunc.onSecondCall().returns({ outcome: Q.resolve("stdout") });
19 mockedExecFunc.throws();
20
21 const mockExec: any = {
22 exec: mockedExecFunc
23 };
24 const plistBuddy = new PlistBuddy({ nodeChildProcess: mockExec });
25
26 return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
27 .then(() => {
28 if (!mockedExecFunc.calledWithMatch(/Set/)) {
29 throw new Error("plistBuddy did not attempt to set first");
30 }
31 if (!mockedExecFunc.calledWithMatch(/Add/)) {
32 throw new Error("plistBuddy did not attempt to add after set failed");
33 }
34 if (mockedExecFunc.callCount > 2) {
35 throw new Error("plistBuddy attempted to execute too often");
36 }
37 });
38 });
39 });
40});