-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Provide more options for starting dehydration #4664
Provide more options for starting dehydration #4664
Conversation
}, | ||
}); | ||
|
||
fetchMock.mockClear(); |
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 would prefer the above setup code to be in a function that takes arguments for the exact setup we need e.g. function setup(key_cached: boolean, device_exists: boolean, ...) ...
and then separate tests for the things we want to be true:
it("should do nothing if no key is cached and onlyIfKeyCached is true")
it("should create a new key and device if no key or device exist")
it("should rehydrate an existing device using the existing key if it exists")
it("should create a new device if we don't have the key for the existing device")
it("should create a new device even if one exists if rehdrate is false")
it("should create a new device every time if createNewKey is true")
This would really help me understand what the code is supposed to do, and will help us understand what happened if future code changes affect this logic.
This is a preference, so if you have good reasons for this narrative style, you can ignore this request :-)
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.
Changed.
The narrative style made sense when I was writing it, but this is probably clearer.
Needed for starting dehydration after restart -- since we only want to do that if we already have a key cached, and we don't need to try to rehydrate a device.
Fixes #4484
Checklist
public
/exported
symbols have accurate TSDoc documentation.