-
Notifications
You must be signed in to change notification settings - Fork 1
fix: added components tests to increase coverage to 80% #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ash-wright123
merged 10 commits into
aw/CT-2264_src_tests
from
aw/CT-2264_components_tests
Jun 26, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
96ded32
fix: added components tests to increase coverage to 80%
ash-wright123 bff1c58
moved test files by the files they are testing
ash-wright123 228dc51
simplified insitution header test
ash-wright123 12097d5
simplified container test
ash-wright123 2e67c7d
refactored delete member survey
ash-wright123 4f1c2df
used constants
ash-wright123 b307bd1
detail review item test without mocks
ash-wright123 7a943e8
moved data test to actual svg
ash-wright123 d4e6a2b
addressed MR comments
ash-wright123 e8d7e7d
removes stepwrapper from render connect test
ash-wright123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,56 @@ | ||
| import React from 'react' | ||
| import { describe, it, expect } from 'vitest' | ||
| import { render, screen } from 'src/utilities/testingLibrary' | ||
| import { ConnectInstitutionHeader } from 'src/components/ConnectInstitutionHeader' | ||
| import { COLOR_SCHEME } from 'src/const/Connect' | ||
| import { initialState } from 'src/services/mockedData' | ||
|
|
||
| describe('ConnectInstitutionHeader', () => { | ||
| const createPreloadedState = (colorScheme: string) => ({ | ||
| ...initialState, | ||
| config: { | ||
| ...initialState.config, | ||
| color_scheme: colorScheme, | ||
| }, | ||
| }) | ||
|
|
||
| it('renders light backdrop when color scheme is LIGHT', () => { | ||
| const preloadedState = createPreloadedState(COLOR_SCHEME.LIGHT) | ||
| render(<ConnectInstitutionHeader />, { preloadedState }) | ||
|
|
||
| expect(screen.getByTestId('backdrop-light')).toBeInTheDocument() | ||
| expect(screen.queryByTestId('backdrop-dark')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders dark backdrop when color scheme is DARK', () => { | ||
| const preloadedState = createPreloadedState(COLOR_SCHEME.DARK) | ||
| render(<ConnectInstitutionHeader />, { preloadedState }) | ||
|
|
||
| expect(screen.getByTestId('backdrop-dark')).toBeInTheDocument() | ||
| expect(screen.queryByTestId('backdrop-light')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders HeaderDevice', () => { | ||
| const preloadedState = createPreloadedState(COLOR_SCHEME.LIGHT) | ||
| render(<ConnectInstitutionHeader />, { preloadedState }) | ||
|
|
||
| expect(screen.getByTestId('device-svg')).toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders InstitutionLogo when institutionGuid is provided', () => { | ||
| const preloadedState = createPreloadedState(COLOR_SCHEME.LIGHT) | ||
| render(<ConnectInstitutionHeader institutionGuid="INS-12345" />, { | ||
| preloadedState, | ||
| }) | ||
|
|
||
| expect(screen.getByTestId('institution-logo')).toBeInTheDocument() | ||
| expect(screen.queryByTestId('default-institution-icon')).not.toBeInTheDocument() | ||
| }) | ||
|
|
||
| it('renders default institution icon when institutionGuid is not provided', () => { | ||
| const preloadedState = createPreloadedState(COLOR_SCHEME.LIGHT) | ||
| render(<ConnectInstitutionHeader />, { preloadedState }) | ||
|
|
||
| expect(screen.getByTestId('default-institution-icon')).toBeInTheDocument() | ||
| }) | ||
| }) |
This file contains hidden or 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 hidden or 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,35 @@ | ||
| import React from 'react' | ||
| import { describe, it, expect } from 'vitest' | ||
| import { render } from 'src/utilities/testingLibrary' | ||
| import { Container } from 'src/components/Container' | ||
| import { STEPS } from 'src/const/Connect' | ||
| import { initialState } from 'src/services/mockedData' | ||
|
|
||
| describe('Container', () => { | ||
| const preloadedState = initialState | ||
|
|
||
| it('renders', () => { | ||
| const { container } = render( | ||
| <Container> | ||
| <div>Content</div> | ||
| </Container>, | ||
| { preloadedState }, | ||
| ) | ||
|
|
||
| const containerDiv = container.querySelector('[data-test="container"]') | ||
| expect(containerDiv).toBeInTheDocument() | ||
| expect(containerDiv).not.toHaveStyle({ maxHeight: '100%' }) | ||
| }) | ||
|
|
||
| it('applies maxHeight when step is SEARCH', () => { | ||
| const { container } = render( | ||
| <Container step={STEPS.SEARCH}> | ||
| <div>Content</div> | ||
| </Container>, | ||
| { preloadedState }, | ||
| ) | ||
|
|
||
| const containerDiv = container.querySelector('[data-test="container"]') | ||
| expect(containerDiv).toHaveStyle({ maxHeight: '100%' }) | ||
| }) | ||
| }) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.