Skip to content
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

Fix FormulaWidgetUI render when data is zero #128

Merged
merged 3 commits into from
Mar 22, 2021
Merged

Conversation

VictorVelarde
Copy link
Contributor

When data was 0, a render was not happening, leaving the widget with the previous value, causing a bug

image

@VictorVelarde VictorVelarde requested a review from AdriSolid March 21, 2021 21:08
When data was 0, a render was not happening, leaving the widget with the previous value, causing a bug
@coveralls
Copy link
Collaborator

coveralls commented Mar 21, 2021

Pull Request Test Coverage Report for Build 676585242

  • 2 of 4 (50.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.5%) to 80.179%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/react-ui/src/widgets/utils/animations.js 2 4 50.0%
Totals Coverage Status
Change from base Build 668689666: 1.5%
Covered Lines: 581
Relevant Lines: 690

💛 - Coveralls

@@ -3,15 +3,6 @@ import { render, screen } from '@testing-library/react';
import FormulaWidgetUI from '../../src/widgets/FormulaWidgetUI';
import { currencyFormatter } from './testUtils';

// Mock animations
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this cause I noticed these tests were unstable, when using the real animation steps... I guess that adding the rerender + await removes the problem, but just for you to know

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -36,6 +27,12 @@ describe('FormulaWidgetUI', () => {
expect(await screen.findByText(DATA.value)).toBeInTheDocument();
});

test('should render the current value', async () => {
const { rerender } = render(<FormulaWidgetUI data={1234} />);
rerender(<FormulaWidgetUI data={0} />);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AdriSolid I was thinking about specific tests, in a different file, for animations, not the test on the widget removing the mock, but I guess this is also nice (if we don't need to use a mock anymore)

Copy link
Contributor

@AdriSolid AdriSolid left a comment

Choose a reason for hiding this comment

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

👍

@VictorVelarde VictorVelarde merged commit 5d22bd1 into master Mar 22, 2021
@VictorVelarde VictorVelarde deleted the fix-formula-zero branch March 22, 2021 15:52
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.

3 participants