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

Create comprehensive tests to check the logic of the entire extension #32

Open
nazmulidris opened this issue Oct 16, 2023 · 2 comments
Open
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@nazmulidris
Copy link
Member

nazmulidris commented Oct 16, 2023

Currently storage.ts isn't well tested. It is not trivial to test the logic here since a lot of the work gets delegated to chrome.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.

Here's a great video on DI: https://www.youtube.com/watch?v=J1f5b4vcxCQ

In tests, we can then pass a fixture for the storage provider that we can use to verify our tests.

@nazmulidris nazmulidris added help wanted Extra attention is needed hacktoberfest good first issue Good for newcomers labels Oct 16, 2023
@superbahbi
Copy link
Contributor

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

@nazmulidris
Copy link
Member Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants