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

expect(object).toBeSet() & expect(object).toBeSetOf(String) #43

Closed
jrencz opened this issue Nov 13, 2015 · 8 comments
Closed

expect(object).toBeSet() & expect(object).toBeSetOf(String) #43

jrencz opened this issue Nov 13, 2015 · 8 comments

Comments

@jrencz
Copy link

jrencz commented Nov 13, 2015

String is an example. It should be able to iterate over the Set and check if all its elements match the given type.

@JamieMason
Copy link
Owner

Thanks @jrencz, would you mind writing some example tests in here? What some key specs would look like using Jasmine-Matchers with this implemented.

@jrencz
Copy link
Author

jrencz commented Nov 13, 2015

.toBeEmptySet would be useful as well

@jrencz
Copy link
Author

jrencz commented Nov 13, 2015

@JamieMason do you have any way to handle host objects that are not present everywhere already defined in the project?

It's easy to write a polyfill but I need to include Symbol polyfill to implement Symbol.toStringTag properly.

@JamieMason
Copy link
Owner

I've not used Symbol before @jrencz, can you explain this some more?

jrencz added a commit to jrencz/Jasmine-Matchers that referenced this issue Nov 13, 2015
jrencz added a commit to jrencz/Jasmine-Matchers that referenced this issue Nov 13, 2015
@jrencz
Copy link
Author

jrencz commented Nov 13, 2015

@JamieMason Symbol is a way to define most of those "magical" JS features present before ES2015. One of those is the host objects ability to define how Object#toString works when an object is passed to it. Set has Set[Symbol.toStringTag] similar to function () { return '[Object Set]'; }

For now I just opted out of testing in browsers without Set implemented, but I'd like you to hint me what to do if you already have a plan for such situations.

@jrencz
Copy link
Author

jrencz commented Nov 13, 2015

and Symbol.iterator would be useful to be able to implement toBeSetOf. But then I'm going to need forOf loop anyway (in the most simple approach)

@JamieMason
Copy link
Owner

Thanks again for raising this @jrencz but I've decided not to add matchers for Set etc. A new project such as jasmine-set-matchers could be useful to people though if you decide to take it on.

@jrencz
Copy link
Author

jrencz commented Feb 9, 2016

ok

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

No branches or pull requests

2 participants