Skip to content

Commit 6c3e9d7

Browse files
committed
feat: add buildEpilog to more commands
1 parent 4cddbcc commit 6c3e9d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+270
-155
lines changed

src/__tests__/commands/apps/authorize.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { jest } from '@jest/globals'
33
import type { ArgumentsCamelCase, Argv } from 'yargs'
44

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

23+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
24+
jest.unstable_mockModule('../../../lib/help.js', () => ({
25+
buildEpilog: buildEpilogMock,
26+
}))
27+
2228
const lambdaAuthBuilderMock = jest.fn<typeof lambdaAuthBuilder>()
2329
jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({
2430
lambdaAuthBuilder: lambdaAuthBuilderMock,
@@ -55,6 +61,7 @@ test('builder', () => {
5561

5662
expect(positionalMock).toHaveBeenCalledTimes(1)
5763
expect(exampleMock).toHaveBeenCalledTimes(1)
64+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
5865
expect(epilogMock).toHaveBeenCalledTimes(1)
5966
})
6067

src/__tests__/commands/apps/create.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
SmartThingsClient,
1010
} from '@smartthings/core-sdk'
1111

12+
import type { buildEpilog } from '../../../lib/help.js'
1213
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
1314
import type { lambdaAuthBuilder } from '../../../lib/command/common-flags.js'
1415
import type { CustomCommonOutputProducer } from '../../../lib/command/format.js'
@@ -29,7 +30,12 @@ import {
2930
} from '../../test-lib/table-mock.js'
3031

3132

32-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
33+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
34+
jest.unstable_mockModule('../../../lib/help.js', () => ({
35+
buildEpilog: buildEpilogMock,
36+
}))
37+
38+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')
3339

3440
const lambdaAuthBuilderMock = jest.fn<typeof lambdaAuthBuilder>()
3541
jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({
@@ -94,7 +100,7 @@ test('builder', () => {
94100

95101
expect(exampleMock).toHaveBeenCalledTimes(1)
96102
expect(optionMock).toHaveBeenCalledTimes(1)
97-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
103+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
98104
expect(epilogMock).toHaveBeenCalledTimes(1)
99105
})
100106

src/__tests__/commands/apps/oauth.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
44

55
import type { AppOAuthResponse, AppsEndpoint } from '@smartthings/core-sdk'
66

7+
import type { buildEpilog } from '../../../lib/help.js'
78
import type { CommandArgs } from '../../../commands/apps/oauth.js'
89
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
910
import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js'
@@ -14,7 +15,12 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
1415
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
1516

1617

17-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
18+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
19+
jest.unstable_mockModule('../../../lib/help.js', () => ({
20+
buildEpilog: buildEpilogMock,
21+
}))
22+
23+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')
1824

1925
const outputItemMock = jest.fn<typeof outputItem>()
2026
const outputItemBuilderMock = jest.fn<typeof outputItemBuilder>()
@@ -54,7 +60,7 @@ test('builder', () => {
5460
expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
5561
expect(positionalMock).toHaveBeenCalledTimes(1)
5662
expect(exampleMock).toHaveBeenCalledTimes(1)
57-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
63+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
5864
expect(epilogMock).toHaveBeenCalledTimes(1)
5965
})
6066

src/__tests__/commands/apps/oauth/generate.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
SmartThingsClient,
1111
} from '@smartthings/core-sdk'
1212

13-
import type { itemInputHelpText } from '../../../../lib/help.js'
13+
import type { itemInputHelpText, buildEpilog } from '../../../../lib/help.js'
1414
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
1515
import type {
1616
inputAndOutputItem,
@@ -25,15 +25,16 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
2525
import { buildInputDefMock } from '../../../test-lib/input-type-mock.js'
2626

2727

28+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
2829
const itemInputHelpTextMock = jest.fn<typeof itemInputHelpText>()
2930
jest.unstable_mockModule('../../../../lib/help.js', () => ({
31+
buildEpilog: buildEpilogMock,
3032
itemInputHelpText: itemInputHelpTextMock,
3133
}))
3234

3335
const {
3436
apiCommandMock,
3537
apiCommandBuilderMock,
36-
apiDocsURLMock,
3738
} = apiCommandMocks('../../../..')
3839

3940
const inputAndOutputItemMock =
@@ -93,7 +94,7 @@ test('builder', () => {
9394

9495
expect(positionalMock).toHaveBeenCalledTimes(1)
9596
expect(exampleMock).toHaveBeenCalledTimes(1)
96-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
97+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
9798
expect(epilogMock).toHaveBeenCalledTimes(1)
9899
})
99100

src/__tests__/commands/apps/oauth/update.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
SmartThingsClient,
1212
} from '@smartthings/core-sdk'
1313

14-
import type { itemInputHelpText } from '../../../../lib/help.js'
14+
import type { itemInputHelpText, buildEpilog } from '../../../../lib/help.js'
1515
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
1616
import type {
1717
inputAndOutputItem,
@@ -26,15 +26,16 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
2626
import { buildInputDefMock } from '../../../test-lib/input-type-mock.js'
2727

2828

29+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
2930
const itemInputHelpTextMock = jest.fn<typeof itemInputHelpText>()
3031
jest.unstable_mockModule('../../../../lib/help.js', () => ({
32+
buildEpilog: buildEpilogMock,
3133
itemInputHelpText: itemInputHelpTextMock,
3234
}))
3335

3436
const {
3537
apiCommandMock,
3638
apiCommandBuilderMock,
37-
apiDocsURLMock,
3839
} = apiCommandMocks('../../../..')
3940

4041
const inputAndOutputItemMock =
@@ -97,7 +98,7 @@ test('builder', () => {
9798

9899
expect(positionalMock).toHaveBeenCalledTimes(1)
99100
expect(exampleMock).toHaveBeenCalledTimes(1)
100-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
101+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
101102
expect(epilogMock).toHaveBeenCalledTimes(1)
102103
})
103104

src/__tests__/commands/apps/register.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
44

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

7-
import { CommandArgs } from '../../../commands/apps/register.js'
7+
import type { CommandArgs } from '../../../commands/apps/register.js'
8+
import type { buildEpilog } from '../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
9-
import { chooseApp } from '../../../lib/command/util/apps-util.js'
10+
import type { chooseApp } from '../../../lib/command/util/apps-util.js'
1011
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
1112
import { buildArgvMock } from '../../test-lib/builder-mock.js'
1213

1314

14-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
15+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
16+
jest.unstable_mockModule('../../../lib/help.js', () => ({
17+
buildEpilog: buildEpilogMock,
18+
}))
19+
20+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')
1521

1622
const chooseAppMock = jest.fn<typeof chooseApp>()
1723
jest.unstable_mockModule('../../../lib/command/util/apps-util.js', () => ({
@@ -42,7 +48,7 @@ test('builder', () => {
4248

4349
expect(positionalMock).toHaveBeenCalledTimes(1)
4450
expect(exampleMock).toHaveBeenCalledTimes(1)
45-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
51+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
4652
expect(epilogMock).toHaveBeenCalledTimes(1)
4753
})
4854

src/__tests__/commands/apps/settings.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { AppsEndpoint, AppSettingsResponse } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../commands/apps/settings.js'
8+
import type { buildEpilog } from '../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
910
import type { CustomCommonOutputProducer } from '../../../lib/command/format.js'
1011
import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js'
1112
import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js'
1213
import type { SmartThingsCommandFlags } from '../../../lib/command/smartthings-command.js'
13-
import { buildTableOutput, type chooseApp } from '../../../lib/command/util/apps-util.js'
14+
import type { buildTableOutput, chooseApp } from '../../../lib/command/util/apps-util.js'
1415
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
1516
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
1617
import { tableGeneratorMock } from '../../test-lib/table-mock.js'
1718

1819

19-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
20+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
21+
jest.unstable_mockModule('../../../lib/help.js', () => ({
22+
buildEpilog: buildEpilogMock,
23+
}))
24+
25+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')
2026

2127
const outputItemMock = jest.fn<typeof outputItem>()
2228
const outputItemBuilderMock = jest.fn<typeof outputItemBuilder>()
@@ -57,7 +63,7 @@ test('builder', () => {
5763
expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
5864
expect(positionalMock).toHaveBeenCalledTimes(1)
5965
expect(exampleMock).toHaveBeenCalledTimes(1)
60-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
66+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
6167
expect(epilogMock).toHaveBeenCalledTimes(1)
6268
})
6369

src/__tests__/commands/apps/settings/update.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
44

55
import type { AppsEndpoint, AppSettingsResponse, SmartThingsClient } from '@smartthings/core-sdk'
66

7+
import type { buildEpilog } from '../../../../lib/help.js'
78
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
89
import type {
910
inputAndOutputItem,
@@ -17,7 +18,12 @@ import { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
1718
import { tableGeneratorMock } from '../../../test-lib/table-mock.js'
1819

1920

20-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
21+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
22+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
23+
buildEpilog: buildEpilogMock,
24+
}))
25+
26+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
2127

2228
const inputAndOutputItemMock = jest.fn<typeof inputAndOutputItem>()
2329
const inputAndOutputItemBuilderMock = jest.fn<typeof inputAndOutputItemBuilder>()
@@ -58,7 +64,7 @@ test('builder', () => {
5864

5965
expect(positionalMock).toHaveBeenCalledTimes(1)
6066
expect(exampleMock).toHaveBeenCalledTimes(1)
61-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
67+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
6268
expect(epilogMock).toHaveBeenCalledTimes(1)
6369
})
6470

src/__tests__/commands/apps/update.test.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,35 @@ import { jest } from '@jest/globals'
22

33
import type { ArgumentsCamelCase, Argv } from 'yargs'
44

5-
import {
6-
type AppCreateRequest,
7-
type AppCreationResponse,
8-
type AppResponse,
9-
type AppsEndpoint,
10-
type AppUpdateRequest,
5+
import type {
6+
AppCreateRequest,
7+
AppCreationResponse,
8+
AppResponse,
9+
AppsEndpoint,
10+
AppUpdateRequest,
1111
} from '@smartthings/core-sdk'
1212

13+
import type { buildEpilog } from '../../../lib/help.js'
1314
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
1415
import type { lambdaAuthBuilder } from '../../../lib/command/common-flags.js'
15-
import {
16+
import type {
1617
inputAndOutputItem,
1718
inputAndOutputItemBuilder,
1819
} from '../../../lib/command/input-and-output-item.js'
19-
import { InputProcessor, userInputProcessor } from '../../../lib/command/input-processor.js'
20+
import type { InputProcessor, userInputProcessor } from '../../../lib/command/input-processor.js'
2021
import { type authorizeApp, type chooseApp, tableFieldDefinitions } from '../../../lib/command/util/apps-util.js'
21-
import { getAppUpdateRequestFromUser } from '../../../lib/command/util/apps-user-input-update.js'
22+
import type { getAppUpdateRequestFromUser } from '../../../lib/command/util/apps-user-input-update.js'
2223
import type { CommandArgs } from '../../../commands/apps/create.js'
2324
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
2425
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
2526

2627

27-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
28+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
29+
jest.unstable_mockModule('../../../lib/help.js', () => ({
30+
buildEpilog: buildEpilogMock,
31+
}))
32+
33+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')
2834

2935
const lambdaAuthBuilderMock = jest.fn<typeof lambdaAuthBuilder>()
3036
jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({
@@ -97,7 +103,7 @@ test('builder', () => {
97103
expect(exampleMock).toHaveBeenCalledTimes(1)
98104
expect(positionalMock).toHaveBeenCalledTimes(1)
99105
expect(optionMock).toHaveBeenCalledTimes(1)
100-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
106+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
101107
expect(epilogMock).toHaveBeenCalledTimes(1)
102108
})
103109

src/__tests__/commands/devicepreferences.test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ import type {
1010
} from '@smartthings/core-sdk'
1111

1212
import type { WithOrganization, forAllOrganizations } from '../../lib/api-helpers.js'
13+
import type { buildEpilog } from '../../lib/help.js'
1314
import type {
1415
APIOrganizationCommand,
1516
APIOrganizationCommandFlags,
1617
apiOrganizationCommand,
1718
apiOrganizationCommandBuilder,
1819
} from '../../lib/command/api-organization-command.js'
19-
import { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/command/common-flags.js'
20-
import { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
21-
import { CommandArgs } from '../../commands/devicepreferences.js'
22-
import { shortARNorURL, verboseApps } from '../../lib/command/util/apps-util.js'
23-
import { apiCommandMocks } from '../test-lib/api-command-mock.js'
20+
import type { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/command/common-flags.js'
21+
import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
22+
import type { CommandArgs } from '../../commands/devicepreferences.js'
2423
import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js'
2524

2625

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

32-
const { apiDocsURLMock } = apiCommandMocks('../..')
31+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
32+
jest.unstable_mockModule('../../lib/help.js', () => ({
33+
buildEpilog: buildEpilogMock,
34+
}))
3335

3436
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
3537
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
@@ -50,14 +52,6 @@ jest.unstable_mockModule('../../lib/command/listing-io.js', () => ({
5052
outputItemOrListBuilder: outputItemOrListBuilderMock,
5153
}))
5254

53-
const shortARNorURLMock = jest.fn<typeof shortARNorURL>()
54-
const verboseAppsMock = jest.fn<typeof verboseApps>()
55-
jest.unstable_mockModule('../../lib/command/util/apps-util.js', () => ({
56-
shortARNorURL: shortARNorURLMock,
57-
verboseApps: verboseAppsMock,
58-
tableFieldDefinitions: [],
59-
}))
60-
6155

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

@@ -89,7 +83,7 @@ test('builder', () => {
8983
expect(positionalMock).toHaveBeenCalledTimes(1)
9084
expect(optionMock).toHaveBeenCalledTimes(2)
9185
expect(exampleMock).toHaveBeenCalledTimes(1)
92-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
86+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
9387
expect(epilogMock).toHaveBeenCalledTimes(1)
9488
})
9589

0 commit comments

Comments
 (0)