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

localStorageStore now delete only items prefixed on version change #8315

Merged
merged 2 commits into from
Oct 27, 2022

Conversation

fzan
Copy link
Contributor

@fzan fzan commented Oct 26, 2022

fix issue on #8312

getStorage().clear();
const storage = getStorage();
Object.keys(storage).forEach(key => {
if (key.startsWith(`${prefix}`)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion:

Suggested change
if (key.startsWith(`${prefix}`)) {
if (key.startsWith(prefix)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, sorry my bad 😅

Comment on lines +43 to +52
describe('reset preserving items outside Ra-Store', () => {
it('should reset the store', () => {
const store = localStorageStore();
store.setItem('foo', 'bar');
getStorage().setItem('baz', 'baz'); //set custom item in localstorage
store.reset();
expect(getStorage().getItem('baz')).toEqual('baz'); //expect not to be wiped on store reset
expect(store.getItem('foo')).toEqual(undefined);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is good (and should be kept), but you are actually not testing the code you added. You should add a test about version change.

Copy link
Contributor Author

@fzan fzan left a comment

Choose a reason for hiding this comment

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

More appropriate test case
Removed use of unneeded literal

@fzaninotto fzaninotto merged commit da3d08b into marmelab:master Oct 27, 2022
@fzaninotto
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants