Skip to content
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

Testing | Add unit tests for "ConfigFile.updateNow" method #63

Closed
6 tasks
jfmdev opened this issue Jul 7, 2021 · 0 comments · Fixed by #72
Closed
6 tasks

Testing | Add unit tests for "ConfigFile.updateNow" method #63

jfmdev opened this issue Jul 7, 2021 · 0 comments · Fixed by #72
Assignees
Labels
enhancement New feature or request estimation-3 3 story points ready-for-review
Milestone

Comments

@jfmdev
Copy link
Contributor

jfmdev commented Jul 7, 2021

Create units test to verify that the ConfigFile.updateNow method works as expected:

  • If the result from fetch is successful, then ConfigFile.parseJSONFile should be called with the file content and result (from updateNow) should be true.
  • If the result from fetch is successful and encryption is enabled, then ConfigFile.parseJSONFile should be called with the unencrypted file content, and result should be true.
  • If fetch throws an exception, then errorMsg (on the local store) shouldn't be null, and result should be false.
  • If fetch returns a response with a 400 status, then errorMsg shouldn't be null, and result should be false.
  • If the file is encrypted but encryption is disabled, then errMsg shouldn't be null, and result should be false.
  • If the file is encrypted but the encryption's key is incorrect, then errMsg shouldn't be null, and result should be false.

Hints:

  • You could create a resources folder (inside test) for define sample JSON files (like one encrypted and other not).
  • Mock the fetch function, so on the tests you don't really fetch an external file (and instead you use local files).

Blocked by #58, related to #57

@jfmdev jfmdev added enhancement New feature or request estimation-3 3 story points labels Jul 7, 2021
@jfmdev jfmdev added this to the v5.1 milestone Jul 7, 2021
@Saidmurod1996 Saidmurod1996 self-assigned this Jul 9, 2021
Saidmurod1996 added a commit that referenced this issue Jul 14, 2021
Saidmurod1996 added a commit that referenced this issue Jul 14, 2021
jfmdev added a commit that referenced this issue Jul 15, 2021
* Issue #63 - unit test for updateNow

* Issue #63 - Don't show console errors from 'updateNow'

Co-authored-by: José <jfmdev@gmail.com>
@jfmdev jfmdev mentioned this issue Jul 15, 2021
4 tasks
@jfmdev jfmdev closed this as completed Jul 15, 2021
jfmdev added a commit that referenced this issue Jul 19, 2021
* Issue #63 - unit test for updateNow

* Issue #64 - add unit for generateJSONFile

* Issue #64 - Minor code fixes

* Issue #64 - add more changes

* Issue #64 - minor change revert

Co-authored-by: José <jfmdev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request estimation-3 3 story points ready-for-review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants