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

Add a unit test for the Delete action #54

Open
estefi-prieto opened this issue Jan 10, 2019 · 8 comments
Open

Add a unit test for the Delete action #54

estefi-prieto opened this issue Jan 10, 2019 · 8 comments
Labels
good first issue Good for newcomers Hacktoberfest (◡ ‿ ◡ ✿) 2019 test

Comments

@estefi-prieto
Copy link
Contributor

estefi-prieto commented Jan 10, 2019

Is your feature request related to a problem? Please describe.
There're no unit tests for the DeleteButton component. It would be nice to implement a simple unit test for that.

Describe the solution you'd like
The test should include:

  • the component initialises with default props
  • the component initialises with given props (those that are not provided by default)
  • onDelete method: the store dispatch method should be called once when clicked
  • onDelete method: the router push method should be called once when clicked

Take the [date input spec] as example.

@estefi-prieto estefi-prieto self-assigned this Jan 10, 2019
@sgobotta sgobotta added the test label Jan 13, 2019
@sgobotta sgobotta added the good first issue Good for newcomers label Sep 14, 2019
@sgobotta sgobotta changed the title Add an e2e test for the Delete action Add a unit test for the Delete action Sep 30, 2019
@sgobotta sgobotta added the Hacktoberfest (◡ ‿ ◡ ✿) 2019 label Sep 30, 2019
@oskar-kupski-elpassion
Copy link

I could give it a try

@sgobotta
Copy link
Member

sgobotta commented Oct 4, 2019

I could give it a try

Alright, comment here if you need any hints.

@oskar-kupski-elpassion
Copy link

What value can I pass as resourceName to make valid dispatch? I tried with 'magazines', so that generated action type in onDelete() method is 'magazines/destroy'

@sgobotta
Copy link
Member

sgobotta commented Oct 4, 2019

What value can I pass as resourceName to make valid dispatch? I tried with 'magazines', so that generated action type in onDelete() method is 'magazines/destroy'

Yeah, hardcoding magazines is ok, or maybe you would like to define a const with the magazines string if you're using it repeatedly across tests.

Here's an example, however it uses constants from the vue-admin core, but it's the same idea.

@oskar-kupski-elpassion
Copy link

hmm, when I tried hardcoding it with magazines I got an error "unknown action type: magazines/destroy"

@sgobotta
Copy link
Member

sgobotta commented Oct 4, 2019

That makes sense if you didn't initialise a mocked store, here's an example of that initialisation.

In your test you'll have to define a fixture in the test/unit/fixtures directory for the delete action spec that declares the storeMethods, like this one

@sgobotta
Copy link
Member

@oskar-kupski-elpassion are you still working on this, do you need any help? If you gave up on this issue please let me know to un-assign you. Thanks!

@oskar-kupski-elpassion
Copy link

oskar-kupski-elpassion commented Oct 14, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Hacktoberfest (◡ ‿ ◡ ✿) 2019 test
Projects
None yet
Development

No branches or pull requests

3 participants