-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
localStorageStore now delete only items prefixed on version change #8315
Conversation
getStorage().clear(); | ||
const storage = getStorage(); | ||
Object.keys(storage).forEach(key => { | ||
if (key.startsWith(`${prefix}`)) { |
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.
suggestion:
if (key.startsWith(`${prefix}`)) { | |
if (key.startsWith(prefix)) { |
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.
oops, sorry my bad 😅
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); | ||
}); | ||
}); |
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.
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.
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.
More appropriate test case
Removed use of unneeded literal
Thanks! |
fix issue on #8312