Open nazmulidris opened 11 months ago
We could use browser.storage.sync
instead of the Chrome storage API. It works similarly, except it supports Chrome, Firefox, and Edge. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/sync
@superbahbi This refactor makes it possible to totally abstract any browser implementation details using DI: https://github.com/r3bl-org/shortlink/blob/main/src/storage/storage_provider_api.ts
This opens the doors for writing comprehensive tests and supporting other browsers and electron environments, etc.
Currently
storage.ts
isn't well tested. It is not trivial to test the logic here since a lot of the work gets delegated tochrome.storage
.We should introduce dependency injection to solve this issue by passing something that wraps chrome.storage or whatever other storage provider we decide to use in the future. We can also introduce an interface type for this storage provider.
In tests, we can then pass a fixture for the storage provider that we can use to verify our tests.