Skip to content
Merged
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
59 changes: 19 additions & 40 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"tail": "^2.2.6"
},
"scripts": {
"test": "node --test",
"test": "node --test --experimental-test-coverage",
"posttest": "npm run eslint",
"eslint": "eslint ."
},
Expand Down
13 changes: 13 additions & 0 deletions test/simctl-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <deviceid>
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')

Expand Down
28 changes: 28 additions & 0 deletions test/simctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
})
})