blob: 13efef677432cce8446d03b40c92a02eda79da90 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001// Copyright 2021 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import React from 'react';
6import {render} from '@testing-library/react';
7import userEvent from '@testing-library/user-event';
8import {screen} from '@testing-library/dom';
9import {assert} from 'chai';
10
11import SelectMenu from './SelectMenu.tsx';
12
13describe('SelectMenu', () => {
14 let container: React.RenderResult;
15
16 beforeEach(() => {
17 container = render(<SelectMenu />).container;
18 });
19
20 it('renders', () => {
21 const form = container.querySelector('form');
22 assert.isNotNull(form)
23 });
24
25 it('renders options on click', () => {
26 const input = document.getElementById('outlined-select-category');
27 if (!input) {
28 throw new Error('Input is undefined');
29 }
30
31 userEvent.click(input)
32
33 // 14 is the current number of options in the select menu
34 const count = screen.getAllByTestId('select-menu-item').length;
35
36 assert.equal(count, 14);
37 });
38});