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
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, CapabilityPresentationCreate, CapabilityPresentation } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/capabilities/presentation/create.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type {
APIOrganizationCommand,
apiOrganizationCommand,
Expand All @@ -19,12 +20,14 @@ import type {
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
import type { chooseCapability } from '../../../../lib/command/util/capabilities-choose.js'
import type { 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', () => {
.toHaveBeenCalledExactlyOnceWith(capabilityIdBuilderArgvMock)

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

Expand Down
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, CapabilityPresentationUpdate, CapabilityPresentation } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/capabilities/presentation/update.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type {
APIOrganizationCommand,
apiOrganizationCommand,
Expand All @@ -19,12 +20,14 @@ import type {
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
import type { chooseCapability } from '../../../../lib/command/util/capabilities-choose.js'
import type { 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', () => {
.toHaveBeenCalledExactlyOnceWith(capabilityIdBuilderArgvMock)

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/capabilities/translations.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, DeviceProfileTranslations, LocaleReference } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../commands/capabilities/translations.js'
import type { buildEpilog } from '../../../lib/help.js'
import type {
APIOrganizationCommand,
APIOrganizationCommandFlags,
Expand All @@ -20,12 +21,14 @@ import type {
} from '../../../lib/command/listing-io.js'
import type { chooseCapability } from '../../../lib/command/util/capabilities-choose.js'
import type { buildTableOutput } from '../../../lib/command/util/capabilities-translations-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 @@ -87,7 +90,7 @@ test('builder', () => {

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

Expand Down
7 changes: 7 additions & 0 deletions src/__tests__/commands/config/reset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'

import type { CommandArgs } from '../../../commands/config/reset.js'
import type { resetManagedConfig } from '../../../lib/cli-config.js'
import type { buildEpilog } from '../../../lib/help.js'
import type { booleanInput } from '../../../lib/user-query.js'
import type {
SmartThingsCommand,
Expand All @@ -14,6 +15,11 @@ import type {
import { buildArgvMock } from '../../test-lib/builder-mock.js'


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

const resetManagedConfigMock = jest.fn<typeof resetManagedConfig>()
jest.unstable_mockModule('../../../lib/cli-config.js', () => ({
resetManagedConfig: resetManagedConfigMock,
Expand Down Expand Up @@ -53,6 +59,7 @@ test('builder', () => {
expect(smartThingsCommandBuilderMock).toHaveBeenCalledExactlyOnceWith(yargsMock)

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

Expand Down
9 changes: 9 additions & 0 deletions src/__tests__/commands/devicepreferences/translations.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 { DevicePreferencesEndpoint, LocaleReference, PreferenceLocalization } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../commands/devicepreferences/translations.js'
import type { buildEpilog } from '../../../lib/help.js'
import type {
APIOrganizationCommand,
apiOrganizationCommand,
Expand All @@ -20,6 +21,11 @@ import { chooseDevicePreference } from '../../../lib/command/util/devicepreferen
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.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 @@ -49,6 +55,7 @@ test('builder', () => {
yargsMock: apiOrganizationCommandBuilderArgvMock,
positionalMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<APIOrganizationCommandFlags, OutputItemOrListFlags>()

Expand All @@ -63,6 +70,8 @@ test('builder', () => {
expect(outputItemOrListBuilderMock).toHaveBeenCalledExactlyOnceWith(apiOrganizationCommandBuilderArgvMock)
expect(positionalMock).toHaveBeenCalledTimes(2)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

describe('handler', () => {
Expand Down
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/devicepreferences/translations/create.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type {
APIOrganizationCommand,
APIOrganizationCommandFlags,
Expand All @@ -26,6 +27,11 @@ import {
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.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', () => {
yargsMock: apiOrganizationCommandBuilderArgvMock,
positionalMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<APIOrganizationCommandFlags, CommandArgs>()

Expand All @@ -73,6 +80,8 @@ test('builder', () => {

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

test('handler', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import { DevicePreferencesEndpoint, PreferenceLocalization } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/devicepreferences/translations/update.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type {
APIOrganizationCommand,
apiOrganizationCommand,
Expand All @@ -20,6 +21,11 @@ import { tableFieldDefinitions } from '../../../../lib/command/util/deviceprefer
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.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 @@ -50,6 +56,7 @@ test('builder', () => {
yargsMock: apiOrganizationCommandBuilderArgvMock,
positionalMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<APIOrganizationCommandFlags, CommandArgs>()

Expand All @@ -66,6 +73,8 @@ test('builder', () => {

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

test('handler', async () => {
Expand Down
9 changes: 9 additions & 0 deletions src/__tests__/commands/edge/channels/metainfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { CommandArgs } from '../../../../commands/edge/channels/metainfo.js

import { ChannelsEndpoint, DriverChannelDetails, EdgeDriver } from '@smartthings/core-sdk'

import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
import type { outputItemOrList, outputItemOrListBuilder } from '../../../../lib/command/listing-io.js'
Expand All @@ -16,6 +17,11 @@ import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock
import { tableGeneratorMock } from '../../../test-lib/table-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<EdgeDriver>>()
Expand Down Expand Up @@ -47,6 +53,7 @@ test('builder', async () => {
positionalMock,
optionMock,
exampleMock,
epilogMock,
argvMock,
} = buildArgvMock<APICommandFlags, CommandArgs>()

Expand All @@ -62,6 +69,8 @@ test('builder', async () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).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/drivers/default.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 { DriversEndpoint, EdgeDriver } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/edge/drivers/default.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { fatalError } from '../../../../lib/util.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
Expand All @@ -15,12 +16,17 @@ import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock
import { tableGeneratorMock } from '../../../test-lib/table-mock.js'


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

const fatalErrorMock = jest.fn<typeof fatalError>().mockReturnValue('never return' as never)
jest.unstable_mockModule('../../../../lib/util.js', () => ({
fatalError: fatalErrorMock,
}))

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

const outputItemOrListMock = jest.fn<typeof outputItemOrList<EdgeDriver>>()
const outputItemOrListBuilderMock = jest.fn<typeof outputItemOrListBuilder>()
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/drivers/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 { DriversEndpoint } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/edge/drivers/delete.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { chooseDriver } from '../../../../lib/command/util/drivers-choose.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 chooseDriverMock = jest.fn<typeof chooseDriver>().mockResolvedValue('chosen-driver-id')
jest.unstable_mockModule('../../../../lib/command/util/drivers-choose.js', () => ({
Expand Down Expand Up @@ -44,7 +50,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/drivers/install.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 { EnrolledChannel, HubdevicesEndpoint } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../../commands/edge/drivers/install.js'
import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type { selectFromList } from '../../../../lib/command/select.js'
import type { chooseDriverFromChannelFn } from '../../../../lib/command/util/drivers-choose.js'
Expand All @@ -15,7 +16,12 @@ 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 selectFromListMock = jest.fn<typeof selectFromList>()
jest.unstable_mockModule('../../../../lib/command/select.js', () => ({
Expand Down Expand Up @@ -61,7 +67,7 @@ test('builder', () => {
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(2)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
Loading