-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit test for composition title (#134)
- Loading branch information
1 parent
c6b0022
commit 7e27909
Showing
3 changed files
with
42 additions
and
6 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
30 changes: 30 additions & 0 deletions
30
ui/src/components/DataViewer/LoadedWithMessageState/LoadedWithMessageState.test.tsx
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,30 @@ | ||
import { parseAPICompositionString } from '@/features/data-table/table/data-grid-utils/oxidation-state-formatter'; | ||
import LoadedWithMessageState from './LoadedWithMessageState'; | ||
import { render, screen, within } from '@testing-library/react'; | ||
|
||
describe('ensure composition title renders correctly', () => { | ||
test('MgO passed as composition title', () => { | ||
const dynamicTitleProp = { | ||
formattedTitle: parseAPICompositionString('MgO'), | ||
unformattedTitle: 'MgO' | ||
}; | ||
render(<LoadedWithMessageState dynamicCompositionTitle={dynamicTitleProp} />); | ||
const compositionTitleElem = screen.getByTestId('dynamic-composition-title'); | ||
expect(compositionTitleElem).toHaveTextContent('MgO'); | ||
}); | ||
|
||
test('LiMn2O4 passed as composition title', () => { | ||
const dynamicTitleProp = { | ||
formattedTitle: parseAPICompositionString('LiMn2O4'), | ||
unformattedTitle: 'LiMn2O4' | ||
}; | ||
render(<LoadedWithMessageState dynamicCompositionTitle={dynamicTitleProp} />); | ||
const compositionTitleElem = screen.getByTestId('dynamic-composition-title'); | ||
const innerSubElem1 = within(compositionTitleElem).getByText('2'); | ||
const innerSubElem2 = within(compositionTitleElem).getByText('4'); | ||
|
||
expect(compositionTitleElem).toHaveTextContent('LiMn2O4'); | ||
expect(innerSubElem1.nodeName).toEqual('SUB'); | ||
expect(innerSubElem2.nodeName).toEqual('SUB'); | ||
}); | ||
}); |
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