Skip to content

Commit

Permalink
Test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Oct 6, 2023
1 parent 02c78ea commit 9cae7fd
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
47 changes: 47 additions & 0 deletions source/frontend/src/components/common/MultiselectTextList.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Api_TypeCode from '@/models/api/TypeCode';
import { render, RenderOptions } from '@/utils/test-utils';

import { IMultiselectTextListProps, MultiselectTextList } from './MultiselectTextList';

const mockOptions: Api_TypeCode<string>[] = [
{ id: 'FOO', description: 'Foo' },
{ id: 'BAR', description: 'Bar' },
{ id: 'BAZ', description: 'Baz' },
];

describe('MultiselectTextList component', () => {
const setup = (
renderOptions?: RenderOptions & { props?: Partial<IMultiselectTextListProps> },
) => {
renderOptions = renderOptions ?? {};
const utils = render(
<MultiselectTextList
{...renderOptions.props}
values={renderOptions.props?.values ?? []}
displayValue={renderOptions.props?.displayValue ?? 'description'}
/>,
{
...renderOptions,
},
);

return { ...utils };
};

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

it('renders as expected', () => {
const { asFragment } = setup();
expect(asFragment()).toMatchSnapshot();
});

it('displays existing values if they exist', () => {
const { getByText } = setup({ props: { values: mockOptions } });

expect(getByText(mockOptions[0].description!)).toBeVisible();
expect(getByText(mockOptions[1].description!)).toBeVisible();
expect(getByText(mockOptions[2].description!)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MultiselectTextList component renders as expected 1`] = `
<DocumentFragment>
<div
class="Toastify"
/>
<div />
<div>
<div
class="multiselect-container multiSelectContainer disable_ms "
id="multiselectContainerReact"
style="opacity: 1;"
>
<div
class="search-wrapper searchWrapper "
style="padding: 0px;"
>
<input
autocomplete="off"
class="searchBox "
disabled=""
id="search_input"
name="search_name_input"
placeholder=""
type="text"
value=""
/>
</div>
<div
class="optionListContainer displayNone"
>
<ul
class="optionContainer"
>
<span
class="notFound"
>
No Options Available
</span>
</ul>
</div>
</div>
</div>
</DocumentFragment>
`;

0 comments on commit 9cae7fd

Please sign in to comment.