go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/ui/src/common/layouts/app_bar/app_menu/app_menu.test.tsx (about)

     1  // Copyright 2023 The LUCI Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  import { render, screen } from '@testing-library/react';
    16  import { destroy } from 'mobx-state-tree';
    17  
    18  import { Store, StoreInstance, StoreProvider } from '@/common/store';
    19  import { FakeContextProvider } from '@/testing_tools/fakes/fake_context_provider';
    20  
    21  import { AppMenu } from './app_menu';
    22  
    23  describe('AppMenu', () => {
    24    let store: StoreInstance;
    25  
    26    beforeEach(() => {
    27      store = Store.create({});
    28    });
    29    afterEach(() => {
    30      destroy(store);
    31    });
    32  
    33    it('should display menu button', async () => {
    34      render(
    35        <StoreProvider value={store}>
    36          <FakeContextProvider>
    37            <AppMenu />
    38          </FakeContextProvider>
    39        </StoreProvider>,
    40      );
    41      await screen.findAllByRole('button');
    42      expect(screen.getByLabelText('Open menu')).toBeInTheDocument();
    43    });
    44  });