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
9 changes: 6 additions & 3 deletions src/__tests__/commands/capabilities/presentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { CapabilitiesEndpoint, SmartThingsClient, CapabilityPresentation } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../commands/capabilities/presentation.js'
import type { buildEpilog } from '../../../lib/help.js'
import type {
APIOrganizationCommand,
APIOrganizationCommandFlags,
Expand All @@ -18,12 +19,14 @@ import type {
import type { CustomCommonOutputProducer, formatAndWriteItem, formatAndWriteItemBuilder } from '../../../lib/command/format.js'
import { chooseCapability } from '../../../lib/command/util/capabilities-choose.js'
import { buildTableOutput } from '../../../lib/command/util/capabilities-presentation-table.js'
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
import { tableGeneratorMock } from '../../test-lib/table-mock.js'


const { apiDocsURLMock } = apiCommandMocks('../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
Expand Down Expand Up @@ -85,7 +88,7 @@ test('builder', () => {

expect(exampleMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
12 changes: 11 additions & 1 deletion src/__tests__/commands/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import type { join } from 'node:path'

import type { ArgumentsCamelCase, Argv } from 'yargs'

import type { Profile, ProfilesByName } from '../../lib/cli-config.js'
import type { CommandArgs } from '../../commands/config.js'
import type { Profile, ProfilesByName } from '../../lib/cli-config.js'
import type { buildEpilog } from '../../lib/help.js'
import type { stringTranslateToId } from '../../lib/command/command-util.js'
import type { TableCommonListOutputProducer, TableCommonOutputProducer } from '../../lib/command/format.js'
import type { outputItemOrListBuilder } from '../../lib/command/listing-io.js'
Expand All @@ -32,6 +33,11 @@ jest.unstable_mockModule('node:path', () => ({
join: joinMock,
}))

const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const stringTranslateToIdMock = jest.fn<typeof stringTranslateToId>()
jest.unstable_mockModule('../../lib/command/command-util.js', () => ({
stringTranslateToId: stringTranslateToIdMock,
Expand Down Expand Up @@ -84,6 +90,7 @@ test('builder', () => {
positionalMock,
optionMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<SmartThingsCommandFlags, BuildOutputFormatterFlags>()

Expand All @@ -96,6 +103,9 @@ test('builder', () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

describe('handler', () => {
Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/edge/channels/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import { ChannelsEndpoint } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/edge/channels/delete.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { CLIConfig, resetManagedConfigKey } from '../../../../lib/cli-config.js'
import type { chooseChannel } from '../../../../lib/command/util/edge/channels-choose.js'
Expand All @@ -17,7 +18,12 @@ jest.unstable_mockModule('../../../../lib/cli-config.js', () => ({
resetManagedConfigKey: resetManagedConfigKeyMock,
}))

const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')

const chooseChannelMock = jest.fn<typeof chooseChannel>().mockResolvedValue('chosen-channel-id')
jest.unstable_mockModule('../../../../lib/command/util/edge/channels-choose.js', () => ({
Expand Down Expand Up @@ -50,7 +56,7 @@ test('builder', () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(0)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/edge/channels/drivers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { jest } from '@jest/globals'
import type { ArgumentsCamelCase, Argv } from 'yargs'

import type { CommandArgs } from '../../../../commands/edge/channels/drivers.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { outputList, outputListBuilder } from '../../../../lib/command/output-list.js'
import type {
Expand All @@ -15,7 +16,12 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'


const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')

const outputListMock = jest.fn<typeof outputList>()
const outputListBuilderMock = jest.fn<typeof outputListBuilder>()
Expand Down Expand Up @@ -62,7 +68,7 @@ test('builder', async () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(0)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/edge/channels/enrollments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { EnrolledChannel, HubdevicesEndpoint } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/edge/channels/enrollments.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { outputList, outputListBuilder } from '../../../../lib/command/output-list.js'
import type { chooseHub } from '../../../../lib/command/util/hubs-choose.js'
import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'


const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')

const outputListMock = jest.fn<typeof outputList>()
const outputListBuilderMock = jest.fn<typeof outputListBuilder>()
Expand Down Expand Up @@ -53,7 +59,7 @@ test('builder', async () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(0)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/locations/rooms/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { RoomsEndpoint } from '@smartthings/core-sdk'

import { CommandArgs } from '../../../../commands/locations/rooms/delete.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { chooseRoom } from '../../../../lib/command/util/rooms-choose.js'
import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
import { buildArgvMock } from '../../../test-lib/builder-mock.js'
import { APICommand } from '../../../../lib/command/api-command.js'


const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')

const chooseRoomMock = jest.fn<typeof chooseRoom>()
jest.unstable_mockModule('../../../../lib/command/util/rooms-choose.js', () => ({
Expand Down Expand Up @@ -45,7 +51,7 @@ test('builder', () => {
expect(optionMock).toHaveBeenCalledTimes(1)
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/locations/rooms/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { Room, RoomRequest, RoomsEndpoint } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/locations/rooms/update.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../../lib/command/input-and-output-item.js'
import type { chooseRoom } from '../../../../lib/command/util/rooms-choose.js'
Expand All @@ -13,7 +14,12 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'


const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')

const inputAndOutputItemMock = jest.fn<typeof inputAndOutputItem>()
const inputAndOutputItemBuilderMock = jest.fn<typeof inputAndOutputItemBuilder>()
Expand Down Expand Up @@ -56,7 +62,7 @@ test('builder', () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
9 changes: 9 additions & 0 deletions src/__tests__/commands/organizations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
} from '@smartthings/core-sdk'

import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js'
import type { buildEpilog } from '../../lib/help.js'
import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
import type { CommandArgs } from '../../commands/organizations.js'
import type { BuildOutputFormatterFlags } from '../../lib/command/output-builder.js'
Expand All @@ -17,6 +18,11 @@ import { apiCommandMocks } from '../test-lib/api-command-mock.js'
import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js'


const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..')

const outputItemOrListMock = jest.fn<typeof outputItemOrList<OrganizationResponse>>()
Expand All @@ -36,6 +42,7 @@ test('builder', () => {
yargsMock: apiCommandBuilderArgvMock,
positionalMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<SmartThingsCommandFlags, BuildOutputFormatterFlags>()

Expand All @@ -50,6 +57,8 @@ test('builder', () => {
expect(outputItemOrListBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

describe('handler', () => {
Expand Down
9 changes: 9 additions & 0 deletions src/__tests__/commands/organizations/current.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
} from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../commands/organizations/current.js'
import type { buildEpilog } from '../../../lib/help.js'
import type {
APIOrganizationCommand,
APIOrganizationCommandFlags,
Expand All @@ -26,6 +27,11 @@ import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js
import { CLIConfig } from '../../../lib/cli-config.js'


const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
jest.unstable_mockModule('../../../lib/command/api-organization-command.js', () => ({
Expand Down Expand Up @@ -57,6 +63,7 @@ test('builder', () => {
const {
yargsMock: apiOrganizationCommandBuilderArgvMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<APIOrganizationCommandFlags, CommandArgs>()

Expand All @@ -72,6 +79,8 @@ test('builder', () => {
.toHaveBeenCalledExactlyOnceWith(apiOrganizationCommandBuilderArgvMock)

expect(exampleMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

describe('handler', () => {
Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/presentation/device-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { PresentationDeviceConfig, PresentationEndpoint } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../commands/presentation/device-config.js'
import type { buildEpilog } from '../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js'
import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js'
Expand All @@ -16,7 +17,12 @@ import { CustomCommonOutputProducer } from '../../../lib/command/format.js'
import { tableGeneratorMock } from '../../test-lib/table-mock.js'


const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')

const outputItemMock = jest.fn<typeof outputItem>()
const outputItemBuilderMock = jest.fn<typeof outputItemBuilder>()
Expand Down Expand Up @@ -55,7 +61,7 @@ test('builder', () => {
expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
expect(positionalMock).toHaveBeenCalledTimes(2)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
10 changes: 8 additions & 2 deletions src/__tests__/commands/scenes/execute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import { type ScenesEndpoint, SmartThingsClient, SuccessStatusValue } from '@smartthings/core-sdk'

import { CommandArgs } from '../../../commands/scenes/execute.js'
import type { buildEpilog } from '../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
import { chooseScene } from '../../../lib/command/util/scenes-util.js'
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
import { buildArgvMock } from '../../test-lib/builder-mock.js'


const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')

const chooseSceneMock = jest.fn<typeof chooseScene>()
jest.unstable_mockModule('../../../lib/command/util/scenes-util.js', () => ({
Expand Down Expand Up @@ -43,7 +49,7 @@ test('builder', () => {

expect(positionalMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
9 changes: 6 additions & 3 deletions src/__tests__/commands/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { SchemaApp, SchemaEndpoint, SmartThingsClient } from '@smartthings/core-sdk'

import { CommandArgs } from '../../commands/schema.js'
import type { buildEpilog } from '../../lib/help.js'
import type {
APIOrganizationCommand,
apiOrganizationCommand,
Expand All @@ -15,13 +16,15 @@ import type { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/co
import { TableCommonListOutputProducer } from '../../lib/command/format.js'
import { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
import { getSchemaAppEnsuringOrganization } from '../../lib/command/util/schema-util.js'
import { apiCommandMocks } from '../test-lib/api-command-mock.js'
import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js'
import { tableGeneratorMock } from '../test-lib/table-mock.js'
import { ValueTableFieldDefinition } from '../../lib/table-generator.js'


const { apiDocsURLMock } = apiCommandMocks('../..')
const buildEpilogMock = jest.fn<typeof buildEpilog>()
jest.unstable_mockModule('../../lib/help.js', () => ({
buildEpilog: buildEpilogMock,
}))

const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
Expand Down Expand Up @@ -81,7 +84,7 @@ test('builder', () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
Loading