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

Add command to reset state #3421

Merged
merged 4 commits into from
Mar 10, 2023
Merged

Add command to reset state #3421

merged 4 commits into from
Mar 10, 2023

Conversation

sroy3
Copy link
Contributor

@sroy3 sroy3 commented Mar 7, 2023

Screen.Recording.2023-03-07.at.5.26.22.PM.mov

@sroy3 sroy3 added the product PR that affects product label Mar 7, 2023
@sroy3 sroy3 self-assigned this Mar 7, 2023
@sroy3 sroy3 marked this pull request as ready for review March 8, 2023 16:35
@sroy3
Copy link
Contributor Author

sroy3 commented Mar 8, 2023

Not really sure how to test this to be honest.

Copy link
Member

@mattseddon mattseddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure how to test this to be honest.

Could have an external function that is registered in the extension. Just give the function the workspace state instead of the whole context. You could then test that function with a mockMemento to make sure all of the correct keys are called. the main reason for adding that test would be to document the behaviour.

Maybe add extension/src/persistence/util.ts & extension/src/persistence/register.ts. Register would take the workspaceState object and so would the util. The test could be done on the util (wouldn't test the registered function as it would cause unexpected result in development)... remember to stub reload window 😁

edit: this is a suggestion.

Copy link
Contributor

@julieg18 julieg18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@sroy3
Copy link
Contributor Author

sroy3 commented Mar 10, 2023

Not really sure how to test this to be honest.

Could have an external function that is registered in the extension. Just give the function the workspace state instead of the whole context. You could then test that function with a mockMemento to make sure all of the correct keys are called. the main reason for adding that test would be to document the behaviour.

Maybe add extension/src/persistence/util.ts & extension/src/persistence/register.ts. Register would take the workspaceState object and so would the util. The test could be done on the util (wouldn't test the registered function as it would cause unexpected result in development)... remember to stub reload window 😁

edit: this is a suggestion.

Thanks that was really useful.

@codeclimate
Copy link

codeclimate bot commented Mar 10, 2023

Code Climate has analyzed commit 93dde1f and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 92.8% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.7% (0.0% change).

View more on Code Climate.

@sroy3 sroy3 merged commit 422f7e6 into main Mar 10, 2023
@sroy3 sroy3 deleted the reset-state branch March 10, 2023 19:34
})
update: (key: string, value: unknown) => {
values[key] = value
void Promise.resolve()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Should this be returned?

Copy link
Contributor Author

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 ever assign the result. Also there is no result to ever be returned. From there, I think it's more of a stylistic choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants