You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
* 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>
Create units test to verify that the
ConfigFile.updateNow
method works as expected:fetch
is successful, thenConfigFile.parseJSONFile
should be called with the file content and result (fromupdateNow
) should be true.fetch
is successful and encryption is enabled, thenConfigFile.parseJSONFile
should be called with the unencrypted file content, and result should be true.fetch
throws an exception, thenerrorMsg
(on the local store) shouldn't be null, and result should be false.fetch
returns a response with a 400 status, thenerrorMsg
shouldn't be null, and result should be false.errMsg
shouldn't be null, and result should be false.errMsg
shouldn't be null, and result should be false.Blocked by #58, related to #57
The text was updated successfully, but these errors were encountered: