go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/frontend/ui/src/components/confirm_dialog/confirm_dialog.test.tsx (about) 1 // Copyright 2022 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 '@testing-library/jest-dom'; 16 17 import { 18 render, 19 screen, 20 } from '@testing-library/react'; 21 22 import { identityFunction } from '@/testing_tools/functions'; 23 24 import ConfirmDialog from './confirm_dialog'; 25 26 describe('Test ConfirmDialog component', () => { 27 it('Given no message, should display title only', async () => { 28 render(<ConfirmDialog 29 onCancel={identityFunction} 30 onConfirm={identityFunction} 31 open/>); 32 await screen.findByText('Are you sure?'); 33 expect(screen.getByText('Are you sure?')).toBeInTheDocument(); 34 }); 35 36 it('Given a message, then should display it', async () => { 37 render(<ConfirmDialog 38 onCancel={identityFunction} 39 onConfirm={identityFunction} 40 message="Test message" 41 open/>); 42 await screen.findByText('Test message'); 43 expect(screen.getByText('Test message')).toBeInTheDocument(); 44 }); 45 });