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
6 changes: 4 additions & 2 deletions redisinsight/ui/src/utils/commands.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { flatten, isArray, isEmpty, reject } from 'lodash'
import { CommandArgsType, CommandGroup, ICommandArg, ICommandArgGenerated } from 'uiSrc/constants'

export const getComplexityShortNotation = (text: string) =>
(text.endsWith(')') && text.startsWith('O') ? text : '')
export const getComplexityShortNotation = (complexity: string[] | string): string => {
const value = isArray(complexity) ? complexity.join(' ') : complexity
return value.endsWith(')') && value.startsWith('O') ? value : ''
}

const generateArgName = (
arg: ICommandArg,
Expand Down
8 changes: 8 additions & 0 deletions redisinsight/ui/src/utils/tests/commands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ describe('getComplexityShortNotation', () => {
}
})
})
it('handle case when complexity is array of strings', () => {
const result = getComplexityShortNotation([
'O(1) for each field/value pair added',
'O(N) to add N field/value pairs when the command is called with multiple field/value pairs.'
])

expect(result).toEqual('')
})
})

describe('generateArgs', () => {
Expand Down