Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-09 15:11:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-09 15:11:14 +0300
commit3fd585614449ccab7fdab083f210c09eb16a6ed2 (patch)
tree225d8bdfcd0bfd5efe0da44348dd97be558be288 /spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js
parent8b50d36626f3a71a2d8552a316d700510559b0de (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js')
-rw-r--r--spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js36
1 files changed, 21 insertions, 15 deletions
diff --git a/spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js b/spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js
index df5b7de78f7..bd1e0dbc15d 100644
--- a/spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js
+++ b/spec/frontend/super_sidebar/components/global_search/command_palette/command_palette_items_spec.js
@@ -5,21 +5,19 @@ import MockAdapter from 'axios-mock-adapter';
import CommandPaletteItems from '~/super_sidebar/components/global_search/command_palette/command_palette_items.vue';
import {
COMMAND_HANDLE,
- COMMANDS_GROUP_TITLE,
USERS_GROUP_TITLE,
USER_HANDLE,
} from '~/super_sidebar/components/global_search/command_palette/constants';
-import { userMapper } from '~/super_sidebar/components/global_search/command_palette/utils';
+import {
+ userMapper,
+ linksReducer,
+} from '~/super_sidebar/components/global_search/command_palette/utils';
import axios from '~/lib/utils/axios_utils';
import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
import waitForPromises from 'helpers/wait_for_promises';
-import { COMMANDS, USERS } from './mock_data';
+import { COMMANDS, LINKS, USERS } from './mock_data';
-const commands = COMMANDS.map(({ text, href, keywords }) => ({
- text,
- href,
- keywords: keywords.join(''),
-}));
+const links = LINKS.reduce(linksReducer, []);
describe('CommandPaletteItems', () => {
let wrapper;
@@ -36,7 +34,8 @@ describe('CommandPaletteItems', () => {
GlDisclosureDropdownItem,
},
provide: {
- commandPaletteData: COMMANDS,
+ commandPaletteCommands: COMMANDS,
+ commandPaletteLinks: LINKS,
},
});
};
@@ -45,24 +44,31 @@ describe('CommandPaletteItems', () => {
const findGroup = () => wrapper.findComponent(GlDisclosureDropdownGroup);
const findLoader = () => wrapper.findComponent(GlLoadingIcon);
- describe('COMMANDS', () => {
+ describe('COMMANDS & LINKS', () => {
it('renders all commands initially', () => {
createComponent();
- expect(findItems()).toHaveLength(COMMANDS.length);
+ const commandGroup = COMMANDS[0];
+ expect(findItems()).toHaveLength(commandGroup.items.length);
expect(findGroup().props('group')).toEqual({
- name: COMMANDS_GROUP_TITLE,
- items: commands,
+ name: commandGroup.name,
+ items: commandGroup.items,
});
});
describe('with search query', () => {
- it('should filter by the search query', async () => {
+ it('should filter comamnds and links by the search query', async () => {
jest.spyOn(fuzzaldrinPlus, 'filter');
createComponent({ searchQuery: 'mr' });
const searchQuery = 'todo';
await wrapper.setProps({ searchQuery });
+ const commandGroup = COMMANDS[0];
+ expect(fuzzaldrinPlus.filter).toHaveBeenCalledWith(
+ commandGroup.items,
+ searchQuery,
+ expect.objectContaining({ key: 'text' }),
+ );
expect(fuzzaldrinPlus.filter).toHaveBeenCalledWith(
- commands,
+ links,
searchQuery,
expect.objectContaining({ key: 'keywords' }),
);