Skip to content

Add tests for ResultsPanel selectors (100% coverage for all selectors)#231

Merged
schoinh merged 60 commits intomainfrom
resultspanel-tests
Aug 11, 2021
Merged

Add tests for ResultsPanel selectors (100% coverage for all selectors)#231
schoinh merged 60 commits intomainfrom
resultspanel-tests

Conversation

@schoinh
Copy link
Copy Markdown
Contributor

@schoinh schoinh commented Aug 10, 2021

Problem

Resolves #182

This is the last PR for the above issue! After this is merged, all selectors in simularium-website will be 100% covered.

Solution

Added tests to the ResultsPanel container's selector and its helper functions, breaking down the functions further to make them more easily testable on the way.

Type of change

Please delete options that are not relevant.

  • This change requires updated or new tests

Steps to Verify:

  1. Check that refactoring the selector and helper functions didn't break the plots. Run npm start, load some models with plots (like endocytosis) and make sure the plots look formatted the same way as before.
  2. GitHub Actions should take care of test coverage check

Keyfiles (delete if not relevant):

  1. src/containers/ResultsPanel/selectors.test.ts - All new tests
  2. src/containers/ResultsPanel/selectors.ts - Broke out configureLayout helper function into smaller functions to make them more easily testable; turned some style values into constants

@schoinh schoinh requested a review from blairlyons as a code owner August 10, 2021 18:32
@schoinh schoinh requested a review from a user August 10, 2021 18:32
@github-actions
Copy link
Copy Markdown

jest coverage report 🧪

Total coverage

Status Category Percentage Covered / Total
🟡 Statements 75.51% (+1.28% 🔼) 518/686
🟡 Branches 70.95% (+1.23% 🔼) 105/148
🔴 Functions 43.75% (+3.03% 🔼) 77/176
🟡 Lines 75.64% (+1.32% 🔼) 500/661

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Show new covered files 🌑

Coverage of new files

Status Filename Statements Branches Functions Lines
🟢 src/containers/ResultsPanel 100% 100% 100% 100%

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

export const getPlotDataConfiguredForPlotly = createSelector(
[getPlotData],
(plotData: RawPlotParams[]): PlotConfig[] => {
if (!plotData) return [];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicate logic so I removed it. TypeScript wouldn't allow a null or undefined or other falsy value to be passed in as plotData. And if plotData were an empty array, the map function below would just return an empty array anyway.

@schoinh schoinh merged commit 0b69a1d into main Aug 11, 2021
@schoinh schoinh deleted the resultspanel-tests branch August 11, 2021 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get 100% unit test coverage on redux selectors

2 participants