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

Offer to help #13

Closed
maxnordlund opened this issue Nov 27, 2018 · 4 comments
Closed

Offer to help #13

maxnordlund opened this issue Nov 27, 2018 · 4 comments

Comments

@maxnordlund
Copy link

Hi, prompted by chaijs/chai#662 (comment) I took a look at this repo, but there hasn't been any activity for a while. I guess it's on someones computer, but I thought I should offer to help.

@keithamus
Copy link
Member

Yes, sadly I broke the cardinal sin of using git! I left the new code on my machine and then my Mac went to the apple store and they formatted my machine despite me telling them not to!

Help is definitely welcome! The biggest drag I had during development was writing tests to catch all the conditions we’d hit.

I’ll come back to this issue in a bit with an action plan on what to do next.

@maxnordlund
Copy link
Author

Yes, sadly I broke the cardinal sin of using git! I left the new code on my machine

Haven't we all 😉 but ...

... and my Mac went to the apple store and they formatted my machine despite me telling them not to!

That's a real bummer 😿

Help is definitely welcome! The biggest drag I had during development was writing tests to catch all the conditions we’d hit.

Tests sounds like fun, and that's something I can definitely contribute once I've seen an example. I guess we could make it super easy using some sort of factory/helper? I can happily write one of those we the time comes. (I have been writing custom assertions for a private project and it's been a real treat to make my tests look ✨ nice ✨)

I’ll come back to this issue in a bit with an action plan on what to do next.

Good, I'm looking forward to it. In the other issue I linked to node's current inspect implementation, I think a fair amount can be borrowed from there. To cut down on the work, right?

@keithamus
Copy link
Member

Hey @maxnordlund! Happy new year!

Over the Christmas holidays I managed to source a slightly outdated backup of loupe@2 code, and get it in working order so we have something that closely resembles what I had before. It lives in the v2 branch and is also over on #14.

Right now test coverage isn't perfect so if you have time to contribute tests that would be 🎉 amazing.

We really need some good acceptance tests to cover some edge cases, to make sure the code is working as it should do. I've written 2 tests to get you started:

describe('arrays', () => {
it('an array of strings truncates the array when it can', () => {
expect(inspect(['foo', 'bar', 'baz', 'bing'], { truncate: 22 })).to.equal("[ 'foo', 'bar', …(2) ]")
})
it('an array of strings truncates the strings when it can', () => {
expect(inspect(['foobarbazbing'], { truncate: 15 })).to.equal("[ 'foobarba…' ]")
})
})

So to write more it's a case of calling inspect() with some object, and wrapping that in a chai expect test, so the whole thing is:

expect(inspect({})).to.equal('{}')

Coming up with some examples is the harder part - finding some objects in your existing code bases or trying to come up with esoteric examples that will break the code would be awesome!

Happy testing!

@keithamus
Copy link
Member

Closing this in favour of #15

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