Skip to content

worked test for LMarker with parent LMap #376

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

Merged
merged 3 commits into from
Apr 22, 2019
Merged

worked test for LMarker with parent LMap #376

merged 3 commits into from
Apr 22, 2019

Conversation

bezany
Copy link
Contributor

@bezany bezany commented Apr 19, 2019

Help for #365
I found solution how mocked $parent as LMap when test other maps components.
Use parentComponent not worked.
Found worked solution here.

@bezany bezany mentioned this pull request Apr 19, 2019
@DonNicoJs
Copy link
Member

@bezany @mikeu how is it more useful? that I merge this? Or wait for mikeu ?

@mikeu
Copy link
Contributor

mikeu commented Apr 21, 2019

@bezany thanks for the help. This looks like a step in the right direction, but I'm not sure if we're all the way there yet. I've only had fifteen minutes to check on this over the weekend, so maybe I've just missed something. I'll put more time into it tomorrow.

For some reason, wrapper.html returns undefined, instead of the content to be rendered. Perhaps we can get away without using this but, for example, I was writing a test for the LZoomControl and was planning to verify that after setting the zoomInText property to something other than '+', the new string did appear in the display as expected.

I also haven't tested any of the other wrapper functions other than setProps, so it's possible this won't be the only strange behaviour.

@DonNicoJs as for how to merge this, I'm happy to get this test in #365 once we sort out any remaining issues, so it all comes as one bundle, or if you want to merge it now then I can pull the changes in from there. Whatever you think is best.

@bezany
Copy link
Contributor Author

bezany commented Apr 22, 2019

@mikeu I did refactoring getWrapper. Now it named getWrapperWithMap. It return component's wrapper and parent map wrapper.
See LMarker.vue default slot text for usage example.
wrapper.html() returns undefined because LMarker render null if not exists default slot. (source code). I added default slot and wait re-render.

@DonNicoJs
Copy link
Member

@bezany @mikeu Please let me know what is best for you :) I will wait to merge on both until I hear from you

@bezany
Copy link
Contributor Author

bezany commented Apr 22, 2019

@DonNicoJs I think you can merge this PR. After this @mikeu continue write unit tests.

@mikeu
Copy link
Contributor

mikeu commented Apr 22, 2019

@bezany Good point about what the component render functions return... The LControlZoom I'd been working with is even worse, it just always returns null. It's now obvious that I should have looked there much earlier in my investigations!

I previously had other approaches that gave the same functionality by having two different wrappers, one for the map and one for the component under test, but I was hoping for a single one. As I said in #365, I was ideally looking to have a single wrapper that provided all of the functionality we'd normally expect for components that could truly be mounted in isolation. I guess what this shows is that that was never going to be possible, since at least some of the components we want to test do not actually render themselves at all, but instead affect what their parent renders. Thanks for pointing that out!

@DonNicoJs I have integrated a version of @bezany's function to return two wrappers, one for the map and one for the component, into the latest addition to #365. I made the minor change of testing whether the component to be mounted already had a created hook, and calling it instead of simply overriding it, if so. Assuming that you are happy with the directory structure and test helpers in that PR, it probably makes the most sense for @bezany to update the LMarker tests to use the wrapper function from there (i.e. import { getWrapperWithMap } from '@/tests/test-helpers') and move them into the components subdirectory, but otherwise use the tests that are already written here. What do you both think?

@mikeu
Copy link
Contributor

mikeu commented Apr 22, 2019

Oh sorry @bezany , I didn't notice that you'd commented while I was working. Sure, @DonNicoJs if you want to merge this as @bezany suggests, then I can pull the updates into my other branch and keep going from there. That sounds good to me.

@DonNicoJs
Copy link
Member

@mikeu I'll merge so that we keep this as clean as possible! @bezany if you want to help mikeu maybe you can collaborate on his fork? I wish I could add you both as collaborator here but I can't :(

@DonNicoJs DonNicoJs merged commit 416df68 into vue-leaflet:master Apr 22, 2019
@bezany bezany deleted the test/LMarker_demo branch April 23, 2019 07:44
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