mirror of
https://github.com/k1tbyte/Wand-Enhancer.git
synced 2026-09-04 16:23:17 +00:00
fix: bump version to 1.0.9.4, update changelog
This commit is contained in:
Vendored
+21
-3
@@ -1,9 +1,10 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { loadStringSet, saveStringSet } from './storage';
|
||||
|
||||
describe('storage revival', () => {
|
||||
beforeEach(() => localStorage.clear());
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
it('revives only valid string ids', () => {
|
||||
localStorage.setItem('pins', JSON.stringify(['one', '', 2, 'two']));
|
||||
@@ -11,9 +12,26 @@ describe('storage revival', () => {
|
||||
});
|
||||
|
||||
it('removes empty sets', () => {
|
||||
saveStringSet('pins', { one: true });
|
||||
expect(saveStringSet('pins', { one: true })).toBe(true);
|
||||
expect(localStorage.getItem('pins')).toBe(JSON.stringify(['one']));
|
||||
saveStringSet('pins', {});
|
||||
expect(saveStringSet('pins', {})).toBe(true);
|
||||
expect(localStorage.getItem('pins')).toBeNull();
|
||||
});
|
||||
|
||||
it('reports a failed browser storage write', () => {
|
||||
vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => {
|
||||
throw new DOMException('Storage disabled', 'SecurityError');
|
||||
});
|
||||
|
||||
expect(saveStringSet('pins', { one: true })).toBe(false);
|
||||
});
|
||||
|
||||
it('handles browsers that block access to local storage', () => {
|
||||
vi.spyOn(window, 'localStorage', 'get').mockImplementation(() => {
|
||||
throw new DOMException('Storage disabled', 'SecurityError');
|
||||
});
|
||||
|
||||
expect(saveStringSet('pins', { one: true })).toBe(false);
|
||||
expect(loadStringSet('pins')).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user