This PR refactors a lot of the internals, and adds tests for most of the public API.
The tests are all unit tests which mock the calls to FillTilt.
Most notable internal change is that each GyroNorm instance has it's own private variables, instead of having those private variables shared between every instance. Those private instance variables are now initialized in the GyroNorm constructor function instead of the init function.
This is a breaking change if you have more than one GyroNorm instance, and assume the data returned in every snapshot callback is the same everywhere (because this is what it used to do, every instance just overwrote the shared state).
Most other refactorings split out functions into smaller functions to improve testability and make the code more readable.
I haven't been able to/don't know how to actually test this on my mobile device, so I haven't verified if everything is still working 😇, will update this PR when breakage occurs.
This PR refactors a lot of the internals, and adds tests for most of the public API. The tests are all unit tests which mock the calls to FillTilt.
Most notable internal change is that each
GyroNorm
instance has it's own private variables, instead of having those private variables shared between every instance. Those private instance variables are now initialized in theGyroNorm
constructor function instead of theinit
function. This is a breaking change if you have more than oneGyroNorm
instance, and assume the data returned in every snapshot callback is the same everywhere (because this is what it used to do, every instance just overwrote the shared state).Most other refactorings split out functions into smaller functions to improve testability and make the code more readable.
I haven't been able to/don't know how to actually test this on my mobile device, so I haven't verified if everything is still working 😇, will update this PR when breakage occurs.