This PR adds tests that cover the vast majority of the code (95% coverage) while making as few changes to the code itself as possible.
Important changes
Add Jest. This also includes Babel since Jest can't deal with ecmascript modules natively.
Make sonos_nfc a function in its own file, so it can easily be executed multiple times in tests.
Inject NFC into sonos_nfc as an argument, allows for easy mocking in tests.
Extract get_sonos_url utility function, allows for easier assertion in tests and is nice to have extracted regardless.
The only code that's currently not covered by tests is the error thrown when a playback command can't be executed. Since that will almost certainly be extracted, it's something I can live with for now. Let me know if you disagee.
Note that this PR also contains the changes from the Prettier PR. Those will disappear as soon as that's merged to master. I suggest not reviewing this PR before that time :)
This PR adds tests that cover the vast majority of the code (95% coverage) while making as few changes to the code itself as possible.
Important changes
sonos_nfc
a function in its own file, so it can easily be executed multiple times in tests.get_sonos_url
utility function, allows for easier assertion in tests and is nice to have extracted regardless.The only code that's currently not covered by tests is the error thrown when a playback command can't be executed. Since that will almost certainly be extracted, it's something I can live with for now. Let me know if you disagee.
Note that this PR also contains the changes from the Prettier PR. Those will disappear as soon as that's merged to master. I suggest not reviewing this PR before that time :)