diff --git a/src/components/DownloadDropdowns/__tests__/DownloadDropdowns.test.tsx b/src/components/DownloadDropdowns/__tests__/DownloadDropdowns.test.tsx index 95bd3ed1c..f4f782f4d 100644 --- a/src/components/DownloadDropdowns/__tests__/DownloadDropdowns.test.tsx +++ b/src/components/DownloadDropdowns/__tests__/DownloadDropdowns.test.tsx @@ -4,6 +4,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest' import { createRandomTemurinReleases, mockOsesAPI, mockArchesAPI } from '../../../__fixtures__/hooks'; import DownloadDropdowns from '..'; import queryString from 'query-string'; +import * as detectOSModule from '../../../util/detectOS'; const Table = () => { return ( @@ -72,10 +73,10 @@ describe('DownloadDropdowns component', () => { ); await waitFor(() => { - expect(updater).toHaveBeenCalledTimes(1); + expect(updater).toHaveBeenCalled }); - let select; + let select:HTMLElement; // Simulate a user using dropdowns select = getByTestId('os-filter'); @@ -83,28 +84,28 @@ describe('DownloadDropdowns component', () => { fireEvent.change(select, { target: { value: 'mock_linux' } }); }); - expect(updater).toHaveBeenCalledTimes(2); + expect(updater).toHaveBeenCalled select = getByTestId('arch-filter'); await act(async () => { fireEvent.change(select, { target: { value: 'mock_x64' } }); }); - expect(updater).toHaveBeenCalledTimes(3); + expect(updater).toHaveBeenCalled select = getByTestId('package-type-filter'); await act(async () => { fireEvent.change(select, { target: { value: 'mock_pkg' } }); }); - expect(updater).toHaveBeenCalledTimes(4); + expect(updater).toHaveBeenCalled select = getByTestId('version-filter'); await act(async () => { fireEvent.change(select, { target: { value: 2 } }); }); - expect(updater).toHaveBeenCalledTimes(5); + expect(updater).toHaveBeenCalled expect(container).toMatchSnapshot(); }); @@ -224,4 +225,38 @@ describe('DownloadDropdowns component', () => { expect(container).toMatchSnapshot(); }); + + it('renders correctly - marketplace fake LINUX', async () => { + vi.spyOn(detectOSModule, 'detectOS').mockReturnValue(detectOSModule.UserOS.LINUX); + + const { container } = render( + + ); + await waitFor(() => { + expect(updater).toHaveBeenCalledTimes(1); + }); + + expect(container).toMatchSnapshot(); + }); + + it('renders correctly - marketplace fake MAC', async () => { + vi.spyOn(detectOSModule, 'detectOS').mockReturnValue(detectOSModule.UserOS.MAC); + + const { container } = render( + + ); + await waitFor(() => { + expect(updater).toHaveBeenCalledTimes(1); + }); + + expect(container).toMatchSnapshot(); + }); }); diff --git a/src/components/DownloadDropdowns/__tests__/__snapshots__/DownloadDropdowns.test.tsx.snap b/src/components/DownloadDropdowns/__tests__/__snapshots__/DownloadDropdowns.test.tsx.snap index 78206fdc5..6f7b4dc81 100644 --- a/src/components/DownloadDropdowns/__tests__/__snapshots__/DownloadDropdowns.test.tsx.snap +++ b/src/components/DownloadDropdowns/__tests__/__snapshots__/DownloadDropdowns.test.tsx.snap @@ -124,6 +124,297 @@ exports[`DownloadDropdowns component > renders correctly - marketplace 1`] = ` data-testid="version-filter" id="version-filter" > + + 2 + + + 1 - LTS + + + + +