Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"grunt-tslint": "3.0.1",
"istanbul": "0.3.19",
"mocha": "2.5.3",
"mocha-fibers": "1.1.1",
"mocha-fibers": "git+https://github.com/NativeScript/mocha-fibers.git",
"mocha-typescript": "1.0.3",
"should": "7.0.2",
"tslint": "3.2.1",
Expand Down
31 changes: 31 additions & 0 deletions test/platform-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {MobilePlatformsCapabilities} from "../lib/mobile-platforms-capabilities"
import {DevicePlatformsConstants} from "../lib/common/mobile/device-platforms-constants";
import { XmlValidator } from "../lib/xml-validator";
import * as ChildProcessLib from "../lib/common/child-process";
import Future = require("fibers/future");
import {CleanCommand} from "../lib/commands/platform-clean";

let isCommandExecuted = true;

Expand Down Expand Up @@ -417,6 +419,35 @@ describe('Platform Service Tests', () => {
commandsService.tryExecuteCommand("platform|clean", ["ios", "invalid"]).wait();
assert.isFalse(isCommandExecuted);
});

it("will call removePlatform and addPlatform on the platformService passing the provided platforms", () => {

let platformActions: { action: string, platforms: string[] }[] = [];
testInjector.registerCommand("platform|clean", CleanCommand);
let cleanCommand = testInjector.resolveCommand("platform|clean");

platformService.removePlatforms = (platforms: string[]) => {
return (() => {
platformActions.push({ action: "removePlatforms", platforms });
}).future<void>()();
};
platformService.addPlatforms = (platforms: string[]) => {
return (() => {
platformActions.push({ action: "addPlatforms", platforms });
}).future<void>()();
}

cleanCommand.execute(["ios"]).wait();

let expectedPlatformActions = [
{ action: "removePlatforms", platforms: ["ios"] },
{ action: "addPlatforms", platforms: ["ios"] },
]

assert.deepEqual(platformActions, expectedPlatformActions, "Expected `remove ios`, `add ios` calls to the platformService.");

assert.isTrue(isCommandExecuted);
});
});

describe("#UpdatePlatformCommand", () => {
Expand Down