Skip to content

Commit a0cdaef

Browse files
author
Artyom Podymov
committed
#RI-2065 - handle case when complexity is array of strings
1 parent 39ea8e1 commit a0cdaef

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

redisinsight/ui/src/utils/commands.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { flatten, isArray, isEmpty, reject } from 'lodash'
22
import { CommandArgsType, CommandGroup, ICommandArg, ICommandArgGenerated } from 'uiSrc/constants'
33

4-
export const getComplexityShortNotation = (text: string) =>
5-
(text.endsWith(')') && text.startsWith('O') ? text : '')
4+
export const getComplexityShortNotation = (complexity: string[] | string): string => {
5+
const value = isArray(complexity) ? complexity.join(' ') : complexity
6+
return value.endsWith(')') && value.startsWith('O') ? value : ''
7+
}
68

79
const generateArgName = (
810
arg: ICommandArg,

redisinsight/ui/src/utils/tests/commands.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ describe('getComplexityShortNotation', () => {
148148
}
149149
})
150150
})
151+
it('handle case when complexity is array of strings', () => {
152+
const result = getComplexityShortNotation([
153+
'O(1) for each field/value pair added',
154+
'O(N) to add N field/value pairs when the command is called with multiple field/value pairs.'
155+
])
156+
157+
expect(result).toEqual('')
158+
})
151159
})
152160

153161
describe('generateArgs', () => {

0 commit comments

Comments
 (0)