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: 8 additions & 1 deletion src/__tests__/commands/apps/authorize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { jest } from '@jest/globals'
import type { ArgumentsCamelCase, Argv } from 'yargs'

import type { CommandArgs } from '../../../commands/apps/authorize.js'
import { addPermission } from '../../../lib/aws-util.js'
import type { addPermission } from '../../../lib/aws-util.js'
import type { buildEpilog } from '../../../lib/help.js'
import type { lambdaAuthBuilder, LambdaAuthFlags } from '../../../lib/command/common-flags.js'
import type {
smartThingsCommand,
Expand All @@ -19,6 +20,11 @@ jest.unstable_mockModule('../../../lib/aws-util.js', () => ({
addPermission: addPermissionMock,
}))

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

const lambdaAuthBuilderMock = jest.fn<typeof lambdaAuthBuilder>()
jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({
lambdaAuthBuilder: lambdaAuthBuilderMock,
Expand Down Expand Up @@ -55,6 +61,7 @@ test('builder', () => {

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

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

import type { buildEpilog } from '../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
import type { lambdaAuthBuilder } from '../../../lib/command/common-flags.js'
import type { CustomCommonOutputProducer } from '../../../lib/command/format.js'
Expand All @@ -29,7 +30,12 @@ import {
} 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 lambdaAuthBuilderMock = jest.fn<typeof lambdaAuthBuilder>()
jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({
Expand Down Expand Up @@ -94,7 +100,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
10 changes: 8 additions & 2 deletions src/__tests__/commands/apps/oauth.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 { AppOAuthResponse, AppsEndpoint } from '@smartthings/core-sdk'

import type { buildEpilog } from '../../../lib/help.js'
import type { CommandArgs } from '../../../commands/apps/oauth.js'
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js'
Expand All @@ -14,7 +15,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 outputItemMock = jest.fn<typeof outputItem>()
const outputItemBuilderMock = jest.fn<typeof outputItemBuilder>()
Expand Down Expand Up @@ -54,7 +60,7 @@ test('builder', () => {
expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
7 changes: 4 additions & 3 deletions src/__tests__/commands/apps/oauth/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
SmartThingsClient,
} from '@smartthings/core-sdk'

import type { itemInputHelpText } from '../../../../lib/help.js'
import type { itemInputHelpText, buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type {
inputAndOutputItem,
Expand All @@ -25,15 +25,16 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
import { buildInputDefMock } from '../../../test-lib/input-type-mock.js'


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

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

const inputAndOutputItemMock =
Expand Down Expand Up @@ -93,7 +94,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
7 changes: 4 additions & 3 deletions src/__tests__/commands/apps/oauth/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
SmartThingsClient,
} from '@smartthings/core-sdk'

import type { itemInputHelpText } from '../../../../lib/help.js'
import type { itemInputHelpText, buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type {
inputAndOutputItem,
Expand All @@ -26,15 +26,16 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
import { buildInputDefMock } from '../../../test-lib/input-type-mock.js'


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

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

const inputAndOutputItemMock =
Expand Down Expand Up @@ -97,7 +98,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
14 changes: 10 additions & 4 deletions src/__tests__/commands/apps/register.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'

import { type AppsEndpoint, AppType, PagedApp } from '@smartthings/core-sdk'

import { CommandArgs } from '../../../commands/apps/register.js'
import type { CommandArgs } from '../../../commands/apps/register.js'
import type { buildEpilog } from '../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
import { chooseApp } from '../../../lib/command/util/apps-util.js'
import type { chooseApp } from '../../../lib/command/util/apps-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 chooseAppMock = jest.fn<typeof chooseApp>()
jest.unstable_mockModule('../../../lib/command/util/apps-util.js', () => ({
Expand Down Expand Up @@ -42,7 +48,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
12 changes: 9 additions & 3 deletions src/__tests__/commands/apps/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
import type { AppsEndpoint, AppSettingsResponse } from '@smartthings/core-sdk'

import type { CommandArgs } from '../../../commands/apps/settings.js'
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 { OutputItemOrListFlags } from '../../../lib/command/listing-io.js'
import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js'
import type { SmartThingsCommandFlags } from '../../../lib/command/smartthings-command.js'
import { buildTableOutput, type chooseApp } from '../../../lib/command/util/apps-util.js'
import type { buildTableOutput, chooseApp } from '../../../lib/command/util/apps-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'


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 @@ -57,7 +63,7 @@ test('builder', () => {
expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
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/apps/settings/update.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 { AppsEndpoint, AppSettingsResponse, SmartThingsClient } from '@smartthings/core-sdk'

import type { buildEpilog } from '../../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
import type {
inputAndOutputItem,
Expand All @@ -17,7 +18,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 inputAndOutputItemMock = jest.fn<typeof inputAndOutputItem>()
const inputAndOutputItemBuilderMock = jest.fn<typeof inputAndOutputItemBuilder>()
Expand Down Expand Up @@ -58,7 +64,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
28 changes: 17 additions & 11 deletions src/__tests__/commands/apps/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@ import { jest } from '@jest/globals'

import type { ArgumentsCamelCase, Argv } from 'yargs'

import {
type AppCreateRequest,
type AppCreationResponse,
type AppResponse,
type AppsEndpoint,
type AppUpdateRequest,
import type {
AppCreateRequest,
AppCreationResponse,
AppResponse,
AppsEndpoint,
AppUpdateRequest,
} from '@smartthings/core-sdk'

import type { buildEpilog } from '../../../lib/help.js'
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
import type { lambdaAuthBuilder } from '../../../lib/command/common-flags.js'
import {
import type {
inputAndOutputItem,
inputAndOutputItemBuilder,
} from '../../../lib/command/input-and-output-item.js'
import { InputProcessor, userInputProcessor } from '../../../lib/command/input-processor.js'
import type { InputProcessor, userInputProcessor } from '../../../lib/command/input-processor.js'
import { type authorizeApp, type chooseApp, tableFieldDefinitions } from '../../../lib/command/util/apps-util.js'
import { getAppUpdateRequestFromUser } from '../../../lib/command/util/apps-user-input-update.js'
import type { getAppUpdateRequestFromUser } from '../../../lib/command/util/apps-user-input-update.js'
import type { CommandArgs } from '../../../commands/apps/create.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 lambdaAuthBuilderMock = jest.fn<typeof lambdaAuthBuilder>()
jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({
Expand Down Expand Up @@ -97,7 +103,7 @@ test('builder', () => {
expect(exampleMock).toHaveBeenCalledTimes(1)
expect(positionalMock).toHaveBeenCalledTimes(1)
expect(optionMock).toHaveBeenCalledTimes(1)
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
expect(epilogMock).toHaveBeenCalledTimes(1)
})

Expand Down
24 changes: 9 additions & 15 deletions src/__tests__/commands/devicepreferences.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import type {
} from '@smartthings/core-sdk'

import type { WithOrganization, forAllOrganizations } from '../../lib/api-helpers.js'
import type { buildEpilog } from '../../lib/help.js'
import type {
APIOrganizationCommand,
APIOrganizationCommandFlags,
apiOrganizationCommand,
apiOrganizationCommandBuilder,
} from '../../lib/command/api-organization-command.js'
import { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/command/common-flags.js'
import { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
import { CommandArgs } from '../../commands/devicepreferences.js'
import { shortARNorURL, verboseApps } from '../../lib/command/util/apps-util.js'
import { apiCommandMocks } from '../test-lib/api-command-mock.js'
import type { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/command/common-flags.js'
import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
import type { CommandArgs } from '../../commands/devicepreferences.js'
import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js'


Expand All @@ -29,7 +28,10 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({
forAllOrganizations: forAllOrganizationsMock,
}))

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 All @@ -50,14 +52,6 @@ jest.unstable_mockModule('../../lib/command/listing-io.js', () => ({
outputItemOrListBuilder: outputItemOrListBuilderMock,
}))

const shortARNorURLMock = jest.fn<typeof shortARNorURL>()
const verboseAppsMock = jest.fn<typeof verboseApps>()
jest.unstable_mockModule('../../lib/command/util/apps-util.js', () => ({
shortARNorURL: shortARNorURLMock,
verboseApps: verboseAppsMock,
tableFieldDefinitions: [],
}))


const { default: cmd } = await import('../../commands/devicepreferences.js')

Expand Down Expand Up @@ -89,7 +83,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