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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const simctl = require('./simctl');
const Destination = require('./destination');
const Runtime = require('./runtime');
const Simulator = require('./simulator');
const process = require('process');
const cp = require('child_process');
const path = require('path');
Expand Down Expand Up @@ -32,3 +34,51 @@ test('specifier with full platform matches runtime and version', () => {
expect(destination.matchesRuntime('com.apple.CoreSimulator.SimRuntime.iOS-12-2')).toEqual(false);
expect(destination.matchesRuntime('com.apple.CoreSimulator.SimRuntime.iOS-13-4')).toEqual(true);
});

test('simulator matches name only', () => {
const runtime = new Runtime("com.apple.CoreSimulator.SimRuntime.iOS-16-0");
const simulator = new Simulator({
udid: "82B24D01-FFB0-4394-9FEE-8AE4D15011D0",
isAvailable: true,
state: "Shutdown",
name: "iPhone 12"
}, runtime);

expect(simulator.matchesInputs("", "iPhone 12", "")).toEqual(true);
});

test('simulator matches full action input set', () => {
const runtime = new Runtime("com.apple.CoreSimulator.SimRuntime.iOS-16-0");
const simulator = new Simulator({
udid: "82B24D01-FFB0-4394-9FEE-8AE4D15011D0",
isAvailable: true,
state: "Shutdown",
name: "iPhone 12"
}, runtime);

expect(simulator.matchesInputs("iOS", "iPhone 12", "16.0")).toEqual(true);
});

test('simulator matches full action input set without minor OS version', () => {
const runtime = new Runtime("com.apple.CoreSimulator.SimRuntime.iOS-16-0");
const simulator = new Simulator({
udid: "82B24D01-FFB0-4394-9FEE-8AE4D15011D0",
isAvailable: true,
state: "Shutdown",
name: "iPhone 12"
}, runtime);

expect(simulator.matchesInputs("iOS", "iPhone 12", "16")).toEqual(true);
});

test('simulator doesn\'t match full action input set with differing OS version', () => {
const runtime = new Runtime("com.apple.CoreSimulator.SimRuntime.iOS-16-0");
const simulator = new Simulator({
udid: "82B24D01-FFB0-4394-9FEE-8AE4D15011D0",
isAvailable: true,
state: "Shutdown",
name: "iPhone 12"
}, runtime);

expect(simulator.matchesInputs("iOS", "iPhone 12", "16.2")).toEqual(false);
});
184 changes: 116 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"homepage": "https://github.com/actions/javascript-action#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1"
"@actions/exec": "^1.1.1",
"semver": "^7.3.8"
},
"devDependencies": {
"@vercel/ncc": "^0.31.1",
Expand Down
14 changes: 1 addition & 13 deletions simctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,7 @@ exports.listSimulators = async() => {
exports.findMatchingSimulator = async(platform, name, os) => {
const simulators = await exports.listSimulators();
const matchingSimulators = simulators.filter(simulator => {
if (simulator.name != name) {
return false;
}

if (platform.length > 0 && simulator.runtime.platform != platform) {
return false;
}

if (os.length > 0 && simulator.runtime.os != os) {
return false;
}

return true;
return simulator.matchesInputs(platform, name, os);
})
.sort((a, b) => {
if (a.runtime.os > b.runtime.os) {
Expand Down
Loading