-
Notifications
You must be signed in to change notification settings - Fork 94
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
chore(tests): add unit tests for js/modules #180
base: master
Are you sure you want to change the base?
chore(tests): add unit tests for js/modules #180
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect these are from the AI generations but far too much of these tests mock major functionality. I am not sure what they are testing with the level of mocking. I would rather properly intercept HTTP requests and not mock anything else. The app should fully function in testing so long HTTP requests to the firmware are mocked.
} | ||
}, | ||
lang: 'en' | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of overwriting the current session in the test, I think I would prefer to change the mocked payload (sinon) for the respective changes. For this example, the /jp and /jo responses would be different to match this test criteria. I think this avoids possible differences in what we expect versus what the firmware sends (also sets us up to support testing different firmware versions).
}; | ||
OSApp.currentDevice = { isMetric: false }; | ||
OSApp.Language = { _: function(key) { return key; } }; | ||
OSApp.Utils = { pad: function(num) { return ('0' + num).slice(-2); } }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be mocking these functions. Why don't we just use the method itself?
} | ||
}; | ||
setTimeout = function(func, delay) {}; | ||
clearTimeout = function(timeout) {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type of mocking doesn't make much sense to me. Why do we need to mock set and clear timeout?
}; | ||
|
||
// Mock OSApp.Errors.showError | ||
originalShowError = OSApp.Errors.showError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be mocking all of this (same comments so will stop making these).
Changes Proposed
/test/tests/modules
folderskip
.OSApp.Firmware.versionCompare
!)npm test
then opentest/reports/Chrome xx/index.html
with your browser (See below)Demo Video or Screenshots
Coverage with this PR. Nowhere near the >= 80% I was hoping for, but at least it's a start!