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

Allow maps to be passed to the empty expectation #463

Merged
merged 4 commits into from Jul 20, 2018

Conversation

graywolf336
Copy link
Contributor

@graywolf336 graywolf336 commented May 10, 2018

Description

This allows Map to be used in the toBeEmpty expectation.

Closes #462

Checklist

  • I am an awesome developer and proud of my code
  • I added / updated / removed relevant unit or integration tests to prove my change works
  • I ran all tests using npm test to make sure everything else still works
  • I ran npm run review to ensure the code adheres to the repository standards

Additional Information

I would love to get some feedback on the code inside the empty-matcher file, I do not like the nested if statements but I couldn't come up with a better way at the time.

As crazy as this sounds, Map keys can be anything, including another object. How should the stringify function handle them? I put a placeholder there to show the size/length of it, but I know that can be improved so it is less confusing.

Also, some reason the npm test command is failing on my Windows machine (I'm away from my usual development environment which is Linux) at the step npm link && install-self.

Copy link
Member

@jamesadarich jamesadarich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks brilliant thanks very much, I'll test this in a bit when I get to my computer but looks good from what I can see. Thanks for the contribution, look forward to your suggestions etc in future :)

@jamesadarich
Copy link
Member

I'll have a look into your Windows issue as well. Does which node and windows version were you using?

Having a ponder about a refactor for EmptyMatcher as well :)

@jamesadarich
Copy link
Member

I've had a thought about a refactor here. Perhaps it makes sense to move the logic to more specific classes that all implement a similar interface instead of abstracted to a common function.

E.g. ArrayMatcher, MapMatcher implement the toBeEmpty function from interface IEmptyMatcher.

Should simplify the individual functions. What are your thoughts @graywolf336?

@graywolf336
Copy link
Contributor Author

Sounds like a fantastic idea 👍 would be allow the empty match to be extended with ease, which I like that.

@pathurs
Copy link
Contributor

pathurs commented Jul 18, 2018

Hey @jamesadarich,

Did you want to accept this PR and create a separate issue for separate matchers?

@jamesadarich
Copy link
Member

Yep @pathurs this sounds like a great plan 👍 I'll create one now, once CI has finished we can get it merged

@jamesadarich
Copy link
Member

thanks @graywolf336 we'll get this published soon 👍

@jamesadarich jamesadarich merged commit edd8c63 into alsatian-test:master Jul 20, 2018
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.

None yet

3 participants