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

Nested looping and ranges #29

Open
stevenvachon opened this issue Jan 27, 2016 · 5 comments
Open

Nested looping and ranges #29

stevenvachon opened this issue Jan 27, 2016 · 5 comments

Comments

@stevenvachon
Copy link

Nested Looping

array = [ [1], [1] ];
expect(array).to.all.all.equal(1);

but then, how would we handle 3+ levels deep?:

expect(array).to.all(3).equal(1);

...but something less mathematical.

Ranged Looping

expect(array).to.each(startIndex, endIndex).equal(1);

Synonyms

each could also be a nice general synonym for all.

@stevenvachon stevenvachon changed the title Nested looping causes grammatical error Nested looping and ranges Jan 27, 2016
@stevenvachon
Copy link
Author

Hello?

@keithamus
Copy link
Member

Hey @stevenvachon sorry I missed this one.

Is this a feature request?

Chai itself already has assertions for looking into arrays, for example your first example could be:

chai.expect([ [1], [1] ]).to.all.contain(1)

@stevenvachon
Copy link
Author

Yes, a feature request. Interesting on all.contain() -- I'll have to try that one out. But, how about array index ranges?

@stevenvachon
Copy link
Author

I'm using this with chai-like:

var obj = { key1:value, key2:value, key3:{key:value} };

expect([ obj, obj ]).to.all.be.like({ key1:value, key2:value });

expect([ [obj], [obj] ]).to.all.all.be.like({ key1:value, key2:value });

@stevenvachon
Copy link
Author

...

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