oneuptime
oneuptime copied to clipboard
Adds tests for Common/Types/Database
Adds tests for Common/Types/Database.
Adds new tests for some of the files in Common/Types/Database directory.
Refactored one test (ColumnLength) to increase test coverage and simplicity.
Upon writing the tests I noticed a couple of issues.
IsPermissionsIfdecorator didn't seem to set the property due to the initial property value in theBaseModel, at least upon testing. Moved the initialization to the constructor and to set only if there isn't a value, to fix this.- Classes that extend
CompareBase, AKA classes that take either a number or a Date as value, "fail" serialization and de-serialization. The value in the end object ends up astring. This commit attempts to fix that as well.
PS: I used Date.toJSON() as it is the method that JSON.stringify would call on a date.
Pull Request Checklist:
- [x] Please make sure all jobs pass before requesting a review.
- [ ] Put
closes #XXXXin your comment to auto-close the issue that your PR fixes (if such). - [x] Have you lint your code locally before submission?
- [x] Did you write tests where appropriate?
Related Issue
#210
@simlarsen it might be a better handling for parsing values that are number | Date.
Instead of handling this individually we could use the "reviver" function of JSON.parse and parse date strings to dates once, wdyt?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#the_reviver_parameter