Skip to content

Commit 576800a

Browse files
committed
feat: add buildEpilog to yet even more commands
1 parent 7efa847 commit 576800a

Some content is hidden

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

46 files changed

+211
-67
lines changed

src/__tests__/commands/capabilities/presentation/create.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { CapabilitiesEndpoint, CapabilityPresentationCreate, CapabilityPresentation } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/capabilities/presentation/create.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type {
910
APIOrganizationCommand,
1011
apiOrganizationCommand,
@@ -19,12 +20,14 @@ import type {
1920
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
2021
import type { chooseCapability } from '../../../../lib/command/util/capabilities-choose.js'
2122
import type { buildTableOutput } from '../../../../lib/command/util/capabilities-presentation-table.js'
22-
import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
2323
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
2424
import { tableGeneratorMock } from '../../../test-lib/table-mock.js'
2525

2626

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

2932
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
3033
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
@@ -85,7 +88,7 @@ test('builder', () => {
8588
.toHaveBeenCalledExactlyOnceWith(capabilityIdBuilderArgvMock)
8689

8790
expect(exampleMock).toHaveBeenCalledTimes(1)
88-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
91+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
8992
expect(epilogMock).toHaveBeenCalledTimes(1)
9093
})
9194

src/__tests__/commands/capabilities/presentation/update.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { CapabilitiesEndpoint, CapabilityPresentationUpdate, CapabilityPresentation } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/capabilities/presentation/update.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type {
910
APIOrganizationCommand,
1011
apiOrganizationCommand,
@@ -19,12 +20,14 @@ import type {
1920
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
2021
import type { chooseCapability } from '../../../../lib/command/util/capabilities-choose.js'
2122
import type { buildTableOutput } from '../../../../lib/command/util/capabilities-presentation-table.js'
22-
import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
2323
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
2424
import { tableGeneratorMock } from '../../../test-lib/table-mock.js'
2525

2626

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

2932
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
3033
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
@@ -85,7 +88,7 @@ test('builder', () => {
8588
.toHaveBeenCalledExactlyOnceWith(capabilityIdBuilderArgvMock)
8689

8790
expect(exampleMock).toHaveBeenCalledTimes(1)
88-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
91+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
8992
expect(epilogMock).toHaveBeenCalledTimes(1)
9093
})
9194

src/__tests__/commands/capabilities/translations.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { CapabilitiesEndpoint, DeviceProfileTranslations, LocaleReference } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../commands/capabilities/translations.js'
8+
import type { buildEpilog } from '../../../lib/help.js'
89
import type {
910
APIOrganizationCommand,
1011
APIOrganizationCommandFlags,
@@ -20,12 +21,14 @@ import type {
2021
} from '../../../lib/command/listing-io.js'
2122
import type { chooseCapability } from '../../../lib/command/util/capabilities-choose.js'
2223
import type { buildTableOutput } from '../../../lib/command/util/capabilities-translations-table.js'
23-
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
2424
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
2525
import { tableGeneratorMock } from '../../test-lib/table-mock.js'
2626

2727

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

3033
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
3134
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
@@ -87,7 +90,7 @@ test('builder', () => {
8790

8891
expect(optionMock).toHaveBeenCalledTimes(2)
8992
expect(epilogMock).toHaveBeenCalledTimes(1)
90-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
93+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
9194
expect(exampleMock).toHaveBeenCalledTimes(1)
9295
})
9396

src/__tests__/commands/config/reset.test.ts

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

55
import type { CommandArgs } from '../../../commands/config/reset.js'
66
import type { resetManagedConfig } from '../../../lib/cli-config.js'
7+
import type { buildEpilog } from '../../../lib/help.js'
78
import type { booleanInput } from '../../../lib/user-query.js'
89
import type {
910
SmartThingsCommand,
@@ -14,6 +15,11 @@ import type {
1415
import { buildArgvMock } from '../../test-lib/builder-mock.js'
1516

1617

18+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
19+
jest.unstable_mockModule('../../../lib/help.js', () => ({
20+
buildEpilog: buildEpilogMock,
21+
}))
22+
1723
const resetManagedConfigMock = jest.fn<typeof resetManagedConfig>()
1824
jest.unstable_mockModule('../../../lib/cli-config.js', () => ({
1925
resetManagedConfig: resetManagedConfigMock,
@@ -53,6 +59,7 @@ test('builder', () => {
5359
expect(smartThingsCommandBuilderMock).toHaveBeenCalledExactlyOnceWith(yargsMock)
5460

5561
expect(exampleMock).toHaveBeenCalledTimes(1)
62+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
5663
expect(epilogMock).toHaveBeenCalledTimes(1)
5764
})
5865

src/__tests__/commands/devicepreferences/translations.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import { DevicePreferencesEndpoint, LocaleReference, PreferenceLocalization } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../commands/devicepreferences/translations.js'
8+
import type { buildEpilog } from '../../../lib/help.js'
89
import type {
910
APIOrganizationCommand,
1011
apiOrganizationCommand,
@@ -20,6 +21,11 @@ import { chooseDevicePreference } from '../../../lib/command/util/devicepreferen
2021
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
2122

2223

24+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
25+
jest.unstable_mockModule('../../../lib/help.js', () => ({
26+
buildEpilog: buildEpilogMock,
27+
}))
28+
2329
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
2430
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
2531
jest.unstable_mockModule('../../../lib/command/api-organization-command.js', () => ({
@@ -49,6 +55,7 @@ test('builder', () => {
4955
yargsMock: apiOrganizationCommandBuilderArgvMock,
5056
positionalMock,
5157
exampleMock,
58+
epilogMock,
5259
argvMock,
5360
} = buildArgvMock<APIOrganizationCommandFlags, OutputItemOrListFlags>()
5461

@@ -63,6 +70,8 @@ test('builder', () => {
6370
expect(outputItemOrListBuilderMock).toHaveBeenCalledExactlyOnceWith(apiOrganizationCommandBuilderArgvMock)
6471
expect(positionalMock).toHaveBeenCalledTimes(2)
6572
expect(exampleMock).toHaveBeenCalledTimes(1)
73+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
74+
expect(epilogMock).toHaveBeenCalledTimes(1)
6675
})
6776

6877
describe('handler', () => {

src/__tests__/commands/devicepreferences/translations/create.test.ts

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

1111
import type { CommandArgs } from '../../../../commands/devicepreferences/translations/create.js'
12+
import type { buildEpilog } from '../../../../lib/help.js'
1213
import type {
1314
APIOrganizationCommand,
1415
APIOrganizationCommandFlags,
@@ -26,6 +27,11 @@ import {
2627
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
2728

2829

30+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
31+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
32+
buildEpilog: buildEpilogMock,
33+
}))
34+
2935
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
3036
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
3137
jest.unstable_mockModule('../../../../lib/command/api-organization-command.js', () => ({
@@ -57,6 +63,7 @@ test('builder', () => {
5763
yargsMock: apiOrganizationCommandBuilderArgvMock,
5864
positionalMock,
5965
exampleMock,
66+
epilogMock,
6067
argvMock,
6168
} = buildArgvMock<APIOrganizationCommandFlags, CommandArgs>()
6269

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

7481
expect(exampleMock).toHaveBeenCalledTimes(1)
7582
expect(positionalMock).toHaveBeenCalledTimes(1)
83+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
84+
expect(epilogMock).toHaveBeenCalledTimes(1)
7685
})
7786

7887
test('handler', async () => {

src/__tests__/commands/devicepreferences/translations/update.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import { DevicePreferencesEndpoint, PreferenceLocalization } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/devicepreferences/translations/update.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type {
910
APIOrganizationCommand,
1011
apiOrganizationCommand,
@@ -20,6 +21,11 @@ import { tableFieldDefinitions } from '../../../../lib/command/util/deviceprefer
2021
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
2122

2223

24+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
25+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
26+
buildEpilog: buildEpilogMock,
27+
}))
28+
2329
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
2430
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
2531
jest.unstable_mockModule('../../../../lib/command/api-organization-command.js', () => ({
@@ -50,6 +56,7 @@ test('builder', () => {
5056
yargsMock: apiOrganizationCommandBuilderArgvMock,
5157
positionalMock,
5258
exampleMock,
59+
epilogMock,
5360
argvMock,
5461
} = buildArgvMock<APIOrganizationCommandFlags, CommandArgs>()
5562

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

6774
expect(exampleMock).toHaveBeenCalledTimes(1)
6875
expect(positionalMock).toHaveBeenCalledTimes(1)
76+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
77+
expect(epilogMock).toHaveBeenCalledTimes(1)
6978
})
7079

7180
test('handler', async () => {

src/__tests__/commands/edge/channels/metainfo.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { CommandArgs } from '../../../../commands/edge/channels/metainfo.js
66

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

9+
import type { buildEpilog } from '../../../../lib/help.js'
910
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
1011
import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js'
1112
import type { outputItemOrList, outputItemOrListBuilder } from '../../../../lib/command/listing-io.js'
@@ -16,6 +17,11 @@ import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock
1617
import { tableGeneratorMock } from '../../../test-lib/table-mock.js'
1718

1819

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

2127
const outputItemOrListMock = jest.fn<typeof outputItemOrList<EdgeDriver>>()
@@ -47,6 +53,7 @@ test('builder', async () => {
4753
positionalMock,
4854
optionMock,
4955
exampleMock,
56+
epilogMock,
5057
argvMock,
5158
} = buildArgvMock<APICommandFlags, CommandArgs>()
5259

@@ -62,6 +69,8 @@ test('builder', async () => {
6269
expect(positionalMock).toHaveBeenCalledTimes(1)
6370
expect(optionMock).toHaveBeenCalledTimes(1)
6471
expect(exampleMock).toHaveBeenCalledTimes(1)
72+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
73+
expect(epilogMock).toHaveBeenCalledTimes(1)
6574
})
6675

6776
describe('handler', () => {

src/__tests__/commands/edge/drivers/default.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { DriversEndpoint, EdgeDriver } from '@smartthings/core-sdk'
66

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

1718

19+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
20+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
21+
buildEpilog: buildEpilogMock,
22+
}))
23+
1824
const fatalErrorMock = jest.fn<typeof fatalError>().mockReturnValue('never return' as never)
1925
jest.unstable_mockModule('../../../../lib/util.js', () => ({
2026
fatalError: fatalErrorMock,
2127
}))
2228

23-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
29+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
2430

2531
const outputItemOrListMock = jest.fn<typeof outputItemOrList<EdgeDriver>>()
2632
const outputItemOrListBuilderMock = jest.fn<typeof outputItemOrListBuilder>()
@@ -62,7 +68,7 @@ test('builder', async () => {
6268
expect(positionalMock).toHaveBeenCalledTimes(1)
6369
expect(optionMock).toHaveBeenCalledTimes(0)
6470
expect(exampleMock).toHaveBeenCalledTimes(1)
65-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
71+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
6672
expect(epilogMock).toHaveBeenCalledTimes(1)
6773
})
6874

src/__tests__/commands/edge/drivers/delete.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { DriversEndpoint } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/edge/drivers/delete.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
910
import type { chooseDriver } from '../../../../lib/command/util/drivers-choose.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 chooseDriverMock = jest.fn<typeof chooseDriver>().mockResolvedValue('chosen-driver-id')
1723
jest.unstable_mockModule('../../../../lib/command/util/drivers-choose.js', () => ({
@@ -44,7 +50,7 @@ test('builder', () => {
4450
expect(positionalMock).toHaveBeenCalledTimes(1)
4551
expect(optionMock).toHaveBeenCalledTimes(0)
4652
expect(exampleMock).toHaveBeenCalledTimes(1)
47-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
53+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
4854
expect(epilogMock).toHaveBeenCalledTimes(1)
4955
})
5056

0 commit comments

Comments
 (0)