vue-admin icon indicating copy to clipboard operation
vue-admin copied to clipboard

Add a unit test for the Delete action

Open estefi-prieto opened this issue 6 years ago • 8 comments

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 avatar Jan 10 '19 18:01 estefi-prieto

I could give it a try

oskar-kupski-elpassion avatar Oct 04 '19 11:10 oskar-kupski-elpassion

I could give it a try

Alright, comment here if you need any hints.

sgobotta avatar Oct 04 '19 11:10 sgobotta

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'

oskar-kupski-elpassion avatar Oct 04 '19 13:10 oskar-kupski-elpassion

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.

sgobotta avatar Oct 04 '19 14:10 sgobotta

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

oskar-kupski-elpassion avatar Oct 04 '19 14:10 oskar-kupski-elpassion

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 avatar Oct 04 '19 15:10 sgobotta

@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!

sgobotta avatar Oct 13 '19 01:10 sgobotta

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!

oskar-kupski-elpassion avatar Oct 14 '19 07:10 oskar-kupski-elpassion