diff --git a/package-lock.json b/package-lock.json index cc31ad7..0854b8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,9 @@ }, "devDependencies": { "@cordova/eslint-config": "^6.0.0" + }, + "engines": { + "node": ">= 14.17.0" } }, "node_modules/@cordova/eslint-config": { @@ -102,7 +105,7 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@eslint/config-helpers/node_modules/@eslint/core": { + "node_modules/@eslint/core": { "version": "0.17.0", "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", @@ -115,19 +118,6 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@eslint/core": { - "version": "0.16.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.16.0.tgz", - "integrity": "sha512-nmC8/totwobIiFcGkDza3GIKfAw1+hLiYVrh3I1nIomQ8PEr5cxg34jnkmGawul/ep52wGRAcyeDCNtWKSOj4Q==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@eslint/eslintrc": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz", @@ -166,9 +156,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.38.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.38.0.tgz", - "integrity": "sha512-UZ1VpFvXf9J06YG9xQBdnzU+kthors6KjhMAl6f4gH4usHyh31rUf2DLGInT8RFYIReYXNSydgPY0V2LuWgl7A==", + "version": "9.39.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.1.tgz", + "integrity": "sha512-S26Stp4zCy88tH94QbBv3XCuzRQiZ9yXofEILmglYTh/Ug/a9/umqvgFtYBAo3Lp0nsI/5/qH1CCrbdK3AP1Tw==", "dev": true, "license": "MIT", "engines": { @@ -202,19 +192,6 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@eslint/plugin-kit/node_modules/@eslint/core": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", - "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", - "dev": true, - "license": "Apache-2.0", - "dependencies": { - "@types/json-schema": "^7.0.15" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -301,6 +278,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -963,20 +941,21 @@ } }, "node_modules/eslint": { - "version": "9.38.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.38.0.tgz", - "integrity": "sha512-t5aPOpmtJcZcz5UJyY2GbvpDlsK5E8JqRqoKtfiKE3cNh437KIqfJr3A3AKf5k64NPx6d0G3dno6XDY05PqPtw==", + "version": "9.39.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.1.tgz", + "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.21.1", - "@eslint/config-helpers": "^0.4.1", - "@eslint/core": "^0.16.0", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", "@eslint/eslintrc": "^3.3.1", - "@eslint/js": "9.38.0", - "@eslint/plugin-kit": "^0.4.0", + "@eslint/js": "9.39.1", + "@eslint/plugin-kit": "^0.4.1", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", @@ -1556,9 +1535,9 @@ } }, "node_modules/globals": { - "version": "16.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-16.4.0.tgz", - "integrity": "sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==", + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.5.0.tgz", + "integrity": "sha512-c/c15i26VrJ4IRt5Z89DnIzCGDn9EcebibhAOjw5ibqEHsE1wLUgkPn9RDmNcUKyU87GeaL633nyJ+pplFR2ZQ==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 511106a..7aa5442 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "tail": "^2.2.6" }, "scripts": { - "test": "node --test", + "test": "node --test --experimental-test-coverage", "posttest": "npm run eslint", "eslint": "eslint ." }, diff --git a/test/simctl-extensions.js b/test/simctl-extensions.js index 594a330..5534658 100644 --- a/test/simctl-extensions.js +++ b/test/simctl-extensions.js @@ -100,6 +100,19 @@ test('start', async (ctx) => { t.assert.equal(console.error.mock.calls[0].arguments[0], `Could not boot simulator ${deviceId}`) }) + await ctx.test('could not get Xcode path', (t) => { + t.assert ||= require('node:assert') + + spawnMock.mock.mockImplementationOnce(() => ({ status: 0, stdout: 'Xcode 13.2.1' }), 0) // xcodebuild -version + spawnMock.mock.mockImplementationOnce(() => ({ status: 0, stdout: JSON.stringify(testJson) }), 1) // xcrun simctl list -j + spawnMock.mock.mockImplementationOnce(() => ({ status: 0 }), 2) // xcrun simctl boot + spawnMock.mock.mockImplementationOnce(() => ({ status: 1 }), 3) // xcode-select -p + + const retObj = SimCtlExtensions.start(deviceId) + t.assert.equal(retObj, undefined) + t.assert.equal(console.error.mock.calls[0].arguments[0], 'Failed to get Xcode path') + }) + await ctx.test('successful start (Xcode >= 9)', (t) => { t.assert ||= require('node:assert') diff --git a/test/simctl.js b/test/simctl.js index 57248aa..8f8835e 100644 --- a/test/simctl.js +++ b/test/simctl.js @@ -180,3 +180,31 @@ test('simctl list', async (ctx) => { t.assert.equal(retObj.json, undefined) }) }) + +test('simctl help', async (ctx) => { + ctx.beforeEach((t) => { + spawnMock.mock.resetCalls() + }) + + await ctx.test('with no arguments', (t) => { + t.assert ||= require('node:assert') + + spawnMock.mock.mockImplementationOnce(() => { + return { status: 0, stdout: '' } + }) + + simctl.help() + t.assert.deepEqual(spawnMock.mock.calls[0].arguments[1], ['simctl', 'help']) + }) + + await ctx.test('with a subcommand', (t) => { + t.assert ||= require('node:assert') + + spawnMock.mock.mockImplementationOnce(() => { + return { status: 0, stdout: '' } + }) + + simctl.help('launch') + t.assert.deepEqual(spawnMock.mock.calls[0].arguments[1], ['simctl', 'help', 'launch']) + }) +})