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

Improve code coverage #73

Open
5 of 6 tasks
mithi opened this issue Jun 18, 2020 · 4 comments · Fixed by #87
Open
5 of 6 tasks

Improve code coverage #73

mithi opened this issue Jun 18, 2020 · 4 comments · Fixed by #87
Labels
best practice Best practice in software development good first issue Good for newcomers help wanted Extra attention is needed PRIORITY Do this first tests Improve code coverage up for grabs

Comments

@mithi mithi added best practice Best practice in software development code quality Refactors to improve code quality good first issue Good for newcomers help wanted Extra attention is needed first-timers-only For people who want to contribute PRIORITY Do this first and removed code quality Refactors to improve code quality labels Jun 18, 2020
@mithi mithi removed the first-timers-only For people who want to contribute label Jun 22, 2020
@mithi
Copy link
Owner Author

mithi commented Jun 24, 2020

Partially fixed by: #87

(from 58 to 77 percent)

@mithi mithi linked a pull request Jun 25, 2020 that will close this issue
@mithi
Copy link
Owner Author

mithi commented Jun 25, 2020

jest.fn()

My simple understanding of these two functions in react/frontend projects is the following:
jest.fn()

    You want to mock a function and really don't care about the original implementation of that function
    Often you just mock the return value
    This is very helpful if you want to remove dependencies to the backend (e.g. when calling backend API) or third party libraries in your tests
    It is also extremly helpful if you want to make real unit tests. You don't care about if certain function that gets called by the unit you test is working properly, because thats not part of it's responsibility.

jest.spyOn()

    The original implementation of the function is relevant for your test, but:
        You want to add your own implementation just for a specific scenario and then reset it again via mockRestore()
        You just want to see if the function was called
        ...
    I think this is especially helpful for integration tests, but not only for them!

Fire Events

fireEvent.change(getByLabelText(/username/i), { target: { value: 'a' } })

fireEvent(node: HTMLElement, event: Event)

// <button>Submit</button>
const rightClick = { button: 2 }
fireEvent.click(getByText('Submit'), rightClick)
// default `button` property for click events is set to `0` which is a left click.

fireEvent.keyDown(domNode, { key: 'Enter', code: 'Enter' })
fireEvent.keyDown(domNode, { key: 'A', code: 'KeyA' })

@mithi
Copy link
Owner Author

mithi commented Jun 25, 2020

App.js

https://codecov.io/gh/mithi/hexapod/src/master/src/App.js

inverse-kinematics

https://codecov.io/gh/mithi/hexapod/src/master/src/components/pages/InverseKinematicsPage.js

  • move tx slider, value near label should update
  • move all 8 sliders and see if PoseTable angles are updated
  • clicking reset will reset all 8 sliders back to zero
  • move all the sliders such that it will be in an unstable position, check back if it triggers an alert saying the expected failure message

Leg Patterns

https://codecov.io/gh/mithi/hexapod/src/master/src/components/pages/LegPatternPage.js

  • move alpha slider, value near its label should change
  • change dimension field tibia to a positive number, value inside the text field should change
  • clicking reset in leg patterns widget should reset all 3 sliders back to zero

DimensionsWidget

https://codecov.io/gh/mithi/hexapod/src/master/src/components/DimensionsWidget.js

  • Toggle the switch (checkbox) the label should change from 1x to 5x and back
  • change dimension field side to a positive number, value inside the text field should change
  • change dimension field femur to a negative number, value inside the text field should NOT change
  • clicking reset in dimensions widget should reset all dimensions field back to default (100)

ForwardKinematicsPage

https://codecov.io/gh/mithi/hexapod/src/master/src/components/pages/ForwardKinematicsPage.js
https://codecov.io/gh/mithi/hexapod/src/master/src/components/pages/LegPoseWidgets.js

  • Toggle the switch (checkbox) we should see 18 sliders instead of 18 spin buttons and back
  • change the leftMiddle-gamma to a negative number, if in slider mode, the value near its label should change
  • change the leftBack-alpha to a non-number character, value inside the text field should NOT change
  • clicking the reset button should reset all the values back to default

NumberInputField

https://codecov.io/gh/mithi/hexapod/src/master/src/components/generic/NumberInputField.js

  • Move the number input field that doesn't match min, max, step, and nan
    it should not update it's value and the error should be displayed at the bottom

Vector.js

https://codecov.io/gh/mithi/hexapod/src/master/src/hexapod/Vector.js
Unit test toMarkdownString()

@mithi mithi added tests tests Improve code coverage and removed tests labels Jun 25, 2020
@mithi mithi pinned this issue Jun 25, 2020
@mithi
Copy link
Owner Author

mithi commented Jul 10, 2020

Try Cypress

@mithi mithi added the first-timers-only For people who want to contribute label Aug 13, 2020
@mithi mithi added up for grabs and removed first-timers-only For people who want to contribute labels Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
best practice Best practice in software development good first issue Good for newcomers help wanted Extra attention is needed PRIORITY Do this first tests Improve code coverage up for grabs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant