-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
370fa8b
commit 32e2cf4
Showing
7 changed files
with
125 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
import { http, HttpResponse } from 'msw'; | ||
import ConfigurationPage from './ConfigurationPage'; | ||
import { getUnifiedConfigs } from '../../util/util'; | ||
import { getGlobalConfigMock } from '../../mocks/globalConfigMock'; | ||
import { type meta as metaType } from '../../types/globalConfig/meta'; | ||
import { mockServerResponseWithContent } from '../../mocks/server-response'; | ||
import { server } from '../../mocks/server'; | ||
|
||
const mockNavigateFn = jest.fn(); | ||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useNavigate: () => mockNavigateFn, | ||
})); | ||
|
||
jest.mock('../../util/util'); | ||
|
||
const getUnifiedConfigsMock = getUnifiedConfigs as jest.Mock; | ||
|
||
beforeEach(() => { | ||
server.use( | ||
http.get(`/servicesNS/nobody/-/:endpointUrl`, () => | ||
HttpResponse.json(mockServerResponseWithContent) | ||
) | ||
); | ||
}); | ||
|
||
function setup(meta: Partial<metaType>) { | ||
const globalConfigMock = getGlobalConfigMock(); | ||
|
||
getUnifiedConfigsMock.mockImplementation(() => ({ | ||
...globalConfigMock, | ||
meta: { | ||
...globalConfigMock.meta, | ||
...meta, | ||
}, | ||
})); | ||
return render(<ConfigurationPage />, { wrapper: BrowserRouter }); | ||
} | ||
|
||
it('should show UCC label', async () => { | ||
const page = setup({ | ||
_uccVersion: undefined, | ||
}); | ||
|
||
const uccLink = page.getByRole('link', { name: /ucc/i }); | ||
expect(uccLink).toBeInTheDocument(); | ||
expect(uccLink.getAttribute('href')).toContain('github.io'); | ||
}); | ||
|
||
it('should not show UCC label', async () => { | ||
const page = setup({ | ||
hideUCCVersion: true, | ||
}); | ||
|
||
const uccLink = page.queryByRole('link', { name: /ucc/i }); | ||
expect(uccLink).toBeNull(); | ||
}); | ||
|
||
it('should show UCC version', async () => { | ||
const uccVersion = '5.2221.2341'; | ||
const page = setup({ | ||
_uccVersion: uccVersion, | ||
}); | ||
|
||
expect(page.getByTestId('ucc-credit')).toHaveTextContent(uccVersion); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters