Skip to content

Commit

Permalink
Merge pull request #248 from memser-spaceport/feat/husky-sidepanel
Browse files Browse the repository at this point in the history
feat/husky-sidepanel: updated husky ask and empty screens
  • Loading branch information
Thangaraj-Ideas2it authored Sep 19, 2024
2 parents 7d15be9 + 85e0e2f commit 0ef5f84
Show file tree
Hide file tree
Showing 20 changed files with 4,676 additions and 859 deletions.
113 changes: 113 additions & 0 deletions __tests__/form/SingleSelectWithImage.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import SingleSelectWithImage from '../../components/form/single-select-with-image';
import '@testing-library/jest-dom';

describe('SingleSelectWithImage Component', () => {
const mockOptions = [
{ id: 1, name: 'Option 1', icon: 'icon1.png' },
{ id: 2, name: 'Option 2', icon: 'icon2.png' },
];

const mockOnItemSelect = jest.fn();

beforeEach(() => {
jest.clearAllMocks();
});

test('renders with default props', () => {
const { getByPlaceholderText } = render(
<SingleSelectWithImage
options={mockOptions}
selectedOption={null}
onItemSelect={mockOnItemSelect}
uniqueKey="id"
displayKey="name"
defaultIcon="default.png"
id="single-select"
/>
);
expect(getByPlaceholderText('Select')).toBeInTheDocument();
});

test('displays label when provided', () => {
const { getByText } = render(
<SingleSelectWithImage
options={mockOptions}
selectedOption={null}
onItemSelect={mockOnItemSelect}
uniqueKey="id"
displayKey="name"
defaultIcon="default.png"
label="Select an option"
id="single-select"
/>
);
expect(getByText('Select an option')).toBeInTheDocument();
});

test('shows options when input is clicked', () => {
const { getByPlaceholderText, getByText } = render(
<SingleSelectWithImage
options={mockOptions}
selectedOption={null}
onItemSelect={mockOnItemSelect}
uniqueKey="id"
displayKey="name"
defaultIcon="default.png"
id="single-select"
/>
);
fireEvent.click(getByPlaceholderText('Select'));
expect(getByText('Option 1')).toBeInTheDocument();
expect(getByText('Option 2')).toBeInTheDocument();
});

test('selects an option when clicked', () => {
const { getByPlaceholderText, getByText } = render(
<SingleSelectWithImage
options={mockOptions}
selectedOption={null}
onItemSelect={mockOnItemSelect}
uniqueKey="id"
displayKey="name"
defaultIcon="default.png"
id="single-select"
/>
);
fireEvent.click(getByPlaceholderText('Select'));
fireEvent.click(getByText('Option 1'));
expect(mockOnItemSelect).toHaveBeenCalledWith(mockOptions[0]);
});

test('shows no results message when filtered options are empty', () => {
const { getByPlaceholderText, getByText } = render(
<SingleSelectWithImage
options={[]}
selectedOption={null}
onItemSelect={mockOnItemSelect}
uniqueKey="id"
displayKey="name"
defaultIcon="default.png"
id="single-select"
/>
);
fireEvent.click(getByPlaceholderText('Select'));
expect(getByText('No results found')).toBeInTheDocument();
});

test('renders selected option correctly', () => {
const { getByPlaceholderText } = render(
<SingleSelectWithImage
options={mockOptions}
selectedOption={mockOptions[0]}
onItemSelect={mockOnItemSelect}
uniqueKey="id"
displayKey="name"
defaultIcon="default.png"
id="single-select"
/>
);
expect(getByPlaceholderText('Select').value).toBe('Option 1');
});
});
4 changes: 4 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ body {
margin-top: 60px;
}

textarea {
font-family:inherit;
}

body {
overflow-y: auto;
}
Expand Down
212 changes: 0 additions & 212 deletions components/core/husky/feedback-modal.tsx

This file was deleted.

Loading

0 comments on commit 0ef5f84

Please sign in to comment.