MetaMask / snaps-cli

A CLI for developing MetaMask plugins.
ISC License
37 stars 26 forks source link

Init Cmd Unit Tests #97

Closed astarinmymind closed 3 years ago

astarinmymind commented 3 years ago

Closer! The most important feedback regards not reusing mocks. I've highlighted some examples thereof, but it'd be good to go through each case thoroughly to ensure that it isn't happening elsewhere.

As long as we're not calling code under test with a particular object and then reusing it for expect(...), that should suffice, although if the mock is reused a lot, creating a getter is probably the way to go (like I suggest in one inline comment).

Finally, the following lines in initHandler and initUtils (respectively) are not being tested, and they're all failure modes / catch blocks.

image

I got coverage on every line except one! I am not creative enough to be able to trigger line 124 in initUtils. The test is commented out, and in the first line attempts to set invalidPermission to something that could trigger that line.