vue-admin
vue-admin copied to clipboard
Add a unit test for the Delete action
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.
I could give it a try
I could give it a try
Alright, comment here if you need any hints.
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'
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.
hmm, when I tried hardcoding it with magazines
I got an error "unknown action type: magazines/destroy"
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
@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!
Please unassign me
On Sun, Oct 13, 2019 at 3:15 AM Santiago Botta [email protected] wrote:
@oskar-kupski-elpassion https://github.com/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!