| b69ab31 | | | 1 | /** |
| b69ab31 | | | 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| b69ab31 | | | 3 | * |
| b69ab31 | | | 4 | * This source code is licensed under the MIT license found in the |
| b69ab31 | | | 5 | * LICENSE file in the root directory of this source tree. |
| b69ab31 | | | 6 | */ |
| b69ab31 | | | 7 | |
| b69ab31 | | | 8 | import {act, fireEvent, render, screen} from '@testing-library/react'; |
| b69ab31 | | | 9 | import App from '../App'; |
| b69ab31 | | | 10 | import platform from '../platform'; |
| b69ab31 | | | 11 | import { |
| b69ab31 | | | 12 | TEST_COMMIT_HISTORY, |
| b69ab31 | | | 13 | expectMessageSentToServer, |
| b69ab31 | | | 14 | resetTestMessages, |
| b69ab31 | | | 15 | simulateCommits, |
| b69ab31 | | | 16 | } from '../testUtils'; |
| b69ab31 | | | 17 | |
| b69ab31 | | | 18 | describe('toasts', () => { |
| b69ab31 | | | 19 | beforeEach(() => { |
| b69ab31 | | | 20 | resetTestMessages(); |
| b69ab31 | | | 21 | render(<App />); |
| b69ab31 | | | 22 | act(() => { |
| b69ab31 | | | 23 | expectMessageSentToServer({ |
| b69ab31 | | | 24 | type: 'subscribe', |
| b69ab31 | | | 25 | kind: 'smartlogCommits', |
| b69ab31 | | | 26 | subscriptionID: expect.anything(), |
| b69ab31 | | | 27 | }); |
| b69ab31 | | | 28 | simulateCommits({ |
| b69ab31 | | | 29 | value: TEST_COMMIT_HISTORY, |
| b69ab31 | | | 30 | }); |
| b69ab31 | | | 31 | }); |
| b69ab31 | | | 32 | }); |
| b69ab31 | | | 33 | |
| b69ab31 | | | 34 | it('shows toast when copying commit hash', () => { |
| b69ab31 | | | 35 | const copySpy = jest.spyOn(platform, 'clipboardCopy').mockImplementation(() => {}); |
| b69ab31 | | | 36 | fireEvent.contextMenu(screen.getByTestId('commit-e')); |
| b69ab31 | | | 37 | fireEvent.click(screen.getByText('Copy Commit Hash "e"')); |
| b69ab31 | | | 38 | expect(screen.getByText('Copied e')).toBeInTheDocument(); |
| b69ab31 | | | 39 | expect(copySpy).toHaveBeenCalledWith('e', undefined); |
| b69ab31 | | | 40 | }); |
| b69ab31 | | | 41 | }); |