Skip to content

Commit f2be7b3

Browse files
author
Kristiyan Ivanov
committed
RI-6188 There is no dropdown to specify how to add elements for adding a new list - tests updated
1 parent a2edfaf commit f2be7b3

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

redisinsight/api/src/modules/browser/list/list.service.spec.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ describe('ListService', () => {
9393
).resolves.not.toThrow();
9494
expect(service.createListWithExpiration).not.toHaveBeenCalled();
9595
});
96+
97+
it('create list with expiration and push at the head', async () => {
98+
when(mockStandaloneRedisClient.sendCommand)
99+
.calledWith([
100+
BrowserToolListCommands.LPush,
101+
mockPushElementDto.keyName,
102+
...mockPushElementDto.elements,
103+
])
104+
.mockResolvedValue(1);
105+
106+
await expect(
107+
service.createList(mockBrowserClientMetadata, mockPushElementDto),
108+
).resolves.not.toThrow();
109+
expect(service.createListWithExpiration).not.toHaveBeenCalled();
110+
});
111+
96112
it('key with this name exist', async () => {
97113
when(mockStandaloneRedisClient.sendCommand)
98114
.calledWith([BrowserToolKeysCommands.Exists, mockPushElementDto.keyName])
@@ -475,7 +491,7 @@ describe('ListService', () => {
475491
it("shouldn't throw error", async () => {
476492
when(mockStandaloneRedisClient.sendPipeline)
477493
.calledWith([
478-
[BrowserToolListCommands.LPush, dto.keyName, ...dto.elements],
494+
[BrowserToolListCommands.RPush, dto.keyName, ...dto.elements],
479495
[BrowserToolKeysCommands.Expire, dto.keyName, dto.expire],
480496
])
481497
.mockResolvedValue([
@@ -490,11 +506,11 @@ describe('ListService', () => {
490506
it('should throw error', async () => {
491507
const replyError: ReplyError = {
492508
...mockRedisNoPermError,
493-
command: 'LPUSH',
509+
command: 'RPUSH',
494510
};
495511
when(mockStandaloneRedisClient.sendPipeline)
496512
.calledWith([
497-
[BrowserToolListCommands.LPush, dto.keyName, ...dto.elements],
513+
[BrowserToolListCommands.RPush, dto.keyName, ...dto.elements],
498514
[BrowserToolKeysCommands.Expire, dto.keyName, dto.expire],
499515
])
500516
.mockResolvedValue([[replyError, []]]);

redisinsight/ui/src/pages/browser/components/add-key/AddKeyList/AddKeyList.spec.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { instance, mock } from 'ts-mockito'
33
import { render, screen, fireEvent } from 'uiSrc/utils/test-utils'
44
import AddKeyList, { Props } from './AddKeyList'
55
import AddKeyFooter from '../AddKeyFooter/AddKeyFooter'
6+
import { HEAD_DESTINATION } from 'uiSrc/pages/browser/modules/key-details/components/list-details/add-list-elements/AddListElements'
67

78
const mockedProps = mock<Props>()
89

@@ -33,6 +34,16 @@ describe('AddKeyList', () => {
3334
expect(valueInput).toHaveValue(value)
3435
})
3536

37+
it('should set destination properly', () => {
38+
render(<AddKeyList {...instance(mockedProps)} />)
39+
const destinationSelect = screen.getByTestId('destination-select')
40+
fireEvent.change(
41+
destinationSelect,
42+
{ target: { value: HEAD_DESTINATION } }
43+
)
44+
expect(destinationSelect).toHaveValue(HEAD_DESTINATION)
45+
})
46+
3647
it('should render disabled add key button with empty keyName', () => {
3748
const { container } = render(<AddKeyList {...instance(mockedProps)} />)
3849
expect(container.querySelector('.btn-add')).toBeDisabled()
@@ -52,7 +63,6 @@ describe('AddKeyList', () => {
5263

5364
it('should not allow deleting the last element', () => {
5465
render(<AddKeyList {...instance(mockedProps)} keyName="name" />)
55-
fireEvent.click(screen.getByTestId('add-item'))
5666
const deleteButtons = screen.getAllByTestId('remove-item')
5767
expect(deleteButtons[0]).toBeDisabled()
5868
})

redisinsight/ui/src/pages/browser/modules/key-details/components/list-details/add-list-elements/AddListElements.spec.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ describe('AddListElements', () => {
4141

4242
it('should not allow deleting the last element', () => {
4343
render(<AddListElements {...instance(mockedProps)} />)
44-
fireEvent.click(screen.getByTestId('add-item'))
4544
const deleteButtons = screen.getAllByTestId('remove-item')
4645
expect(deleteButtons[0]).toBeDisabled()
4746
})

0 commit comments

Comments
 (0)