Skip to content

Commit 4cddbcc

Browse files
committed
refactor: switch to new location of itemInputHelpText, in help.ts
1 parent 082dcc3 commit 4cddbcc

File tree

7 files changed

+26
-41
lines changed

7 files changed

+26
-41
lines changed

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

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

13+
import type { itemInputHelpText } from '../../../../lib/help.js'
1314
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
1415
import type {
1516
inputAndOutputItem,
@@ -24,11 +25,15 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
2425
import { buildInputDefMock } from '../../../test-lib/input-type-mock.js'
2526

2627

28+
const itemInputHelpTextMock = jest.fn<typeof itemInputHelpText>()
29+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
30+
itemInputHelpText: itemInputHelpTextMock,
31+
}))
32+
2733
const {
2834
apiCommandMock,
2935
apiCommandBuilderMock,
3036
apiDocsURLMock,
31-
itemInputHelpTextMock,
3237
} = apiCommandMocks('../../../..')
3338

3439
const inputAndOutputItemMock =

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

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

14+
import type { itemInputHelpText } from '../../../../lib/help.js'
1415
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
1516
import type {
1617
inputAndOutputItem,
@@ -25,11 +26,15 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
2526
import { buildInputDefMock } from '../../../test-lib/input-type-mock.js'
2627

2728

29+
const itemInputHelpTextMock = jest.fn<typeof itemInputHelpText>()
30+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
31+
itemInputHelpText: itemInputHelpTextMock,
32+
}))
33+
2834
const {
2935
apiCommandMock,
3036
apiCommandBuilderMock,
3137
apiDocsURLMock,
32-
itemInputHelpTextMock,
3338
} = apiCommandMocks('../../../..')
3439

3540
const inputAndOutputItemMock =

src/__tests__/lib/command/api-command.test.ts

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import { jest } from '@jest/globals'
22

3-
import { osLocale } from 'os-locale'
3+
import type { osLocale } from 'os-locale'
44

5-
import {
5+
import type {
66
Authenticator,
77
Logger,
88
RESTClientConfig,
99
SmartThingsClient,
1010
WarningFromHeader,
1111
} from '@smartthings/core-sdk'
1212

13-
import {
13+
import type {
1414
SmartThingsCommand,
1515
SmartThingsCommandFlags,
1616
smartThingsCommand,
1717
smartThingsCommandBuilder,
1818
} from '../../../lib/command/smartthings-command.js'
19-
import { newBearerTokenAuthenticator, newSmartThingsClient } from '../../../lib/command/util/st-client-wrapper.js'
20-
import { coreSDKLoggerFromLog4JSLogger } from '../../../lib/log-utils.js'
21-
import { defaultClientIdProvider, loginAuthenticator } from '../../../lib/login-authenticator.js'
22-
import { TableGenerator } from '../../../lib/table-generator.js'
19+
import type { newBearerTokenAuthenticator, newSmartThingsClient } from '../../../lib/command/util/st-client-wrapper.js'
20+
import type { coreSDKLoggerFromLog4JSLogger } from '../../../lib/log-utils.js'
21+
import { defaultClientIdProvider, type loginAuthenticator } from '../../../lib/login-authenticator.js'
22+
import type { TableGenerator } from '../../../lib/table-generator.js'
2323
import { buildArgvMock } from '../../test-lib/builder-mock.js'
24-
import { CLIConfig } from '../../../lib/cli-config.js'
24+
import type { CLIConfig } from '../../../lib/cli-config.js'
2525

2626

2727
const { errorMock, loggerMock } = await import('../../test-lib/logger-mock.js')
@@ -92,7 +92,6 @@ const {
9292
apiCommand,
9393
apiCommandBuilder,
9494
apiDocsURL,
95-
itemInputHelpText,
9695
userAgent,
9796
} = await import('../../../lib/command/api-command.js')
9897

@@ -112,21 +111,6 @@ describe('apiDocsURL', () => {
112111
})
113112
})
114113

115-
describe('itemInputHelpText', () => {
116-
it('works with external URLs', () => {
117-
expect(itemInputHelpText('https://adafruit.com', 'https://digikey.com'))
118-
.toBe('More information can be found at:\n' +
119-
' https://adafruit.com\n' +
120-
' https://digikey.com')
121-
})
122-
123-
it('builds URLs like `apiDocsURL`', () => {
124-
expect(itemInputHelpText('getDevice'))
125-
.toBe('More information can be found at:\n' +
126-
' https://developer.smartthings.com/docs/api/public/#operation/getDevice')
127-
})
128-
})
129-
130114
test('apiCommandBuilder', () => {
131115
const { optionMock, argvMock } = buildArgvMock<SmartThingsCommandFlags>()
132116
smartThingsCommandBuilderMock.mockReturnValueOnce(argvMock)

src/__tests__/test-lib/api-command-mock.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,27 @@ import {
77
type APICommandFlags,
88
type apiCommand,
99
type apiDocsURL,
10-
type itemInputHelpText,
1110
} from '../../lib/command/api-command.js'
1211
import { buildArgvMockStub, type BuilderFunctionMock } from './builder-mock.js'
1312

1413

1514
export const apiCommandMocks = <T extends APICommandFlags = APICommandFlags>(prefix: string): {
1615
apiDocsURLMock: jest.Mock<typeof apiDocsURL>
17-
itemInputHelpTextMock: jest.Mock<typeof itemInputHelpText>
1816
apiCommandMock: jest.Mock<typeof apiCommand>
1917
apiCommandBuilderMock: BuilderFunctionMock<Argv<T>>
2018
} => {
2119
const apiDocsURLMock = jest.fn<typeof apiDocsURL>()
22-
const itemInputHelpTextMock = jest.fn<typeof itemInputHelpText>()
2320
const apiCommandBuilderMock = buildArgvMockStub<T>()
2421
const apiCommandMock = jest.fn<typeof apiCommand>()
2522
jest.unstable_mockModule(`${prefix}/lib/command/api-command.js`, () => ({
2623
userAgent,
2724
apiDocsURL: apiDocsURLMock,
28-
itemInputHelpText: itemInputHelpTextMock,
2925
apiCommandBuilder: apiCommandBuilderMock,
3026
apiCommand: apiCommandMock,
3127
}))
3228

3329
return {
3430
apiDocsURLMock,
35-
itemInputHelpTextMock,
3631
apiCommandBuilderMock,
3732
apiCommandMock,
3833
}

src/commands/apps/oauth/generate.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs'
22

33
import type { GenerateAppOAuthRequest, GenerateAppOAuthResponse } from '@smartthings/core-sdk'
44

5-
import { TableFieldDefinition } from '../../../lib/table-generator.js'
5+
import { itemInputHelpText } from '../../../lib/help.js'
6+
import { type TableFieldDefinition } from '../../../lib/table-generator.js'
67
import {
78
apiCommand,
89
apiCommandBuilder,
9-
APICommandFlags,
10+
type APICommandFlags,
1011
apiDocsURL,
11-
itemInputHelpText,
1212
} from '../../../lib/command/api-command.js'
1313
import {
1414
inputAndOutputItem,
1515
inputAndOutputItemBuilder,
16-
InputAndOutputItemConfig,
17-
InputAndOutputItemFlags,
16+
type InputAndOutputItemConfig,
17+
type InputAndOutputItemFlags,
1818
} from '../../../lib/command/input-and-output-item.js'
1919
import { inputProcessor } from '../../../lib/command/input-processor.js'
2020
import { chooseApp } from '../../../lib/command/util/apps-util.js'

src/commands/apps/oauth/update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs'
22

33
import { AppOAuthRequest } from '@smartthings/core-sdk'
44

5+
import { itemInputHelpText } from '../../../lib/help.js'
56
import {
67
apiCommand,
78
apiCommandBuilder,
89
APICommandFlags,
910
apiDocsURL,
10-
itemInputHelpText,
1111
} from '../../../lib/command/api-command.js'
1212
import {
1313
inputAndOutputItem,

src/lib/command/api-command.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ const toURL = (nameOrURL: string): string => nameOrURL.startsWith('http')
2121

2222
export const apiDocsURL = (...names: string[]): string => 'For API information, see:\n ' +
2323
names.map(name => toURL(name)).join('\n ')
24-
25-
26-
export const itemInputHelpText = (...namesOrURLs: string[]): string => 'More information can be found at:\n ' +
27-
namesOrURLs.map(nameOrURL => toURL(nameOrURL)).join('\n ')
2824
// TODO: END REMOVE
2925

3026
export type APICommandFlags = SmartThingsCommandFlags & {

0 commit comments

Comments
 (0)