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