I'm new to TDD, and I'm trying to learn the right way to do things. So I have to make a javascript class for a web browser extension that stores the user's information to HTML5's localStorage
(I'll call this class UserInfoStorage
). However, I want to make my extension cross-browser compatible, and the way to interact with localStorage
is different across the browsers (Chrome, Firefox, Safari).
Should I make another class called Storage
that is specific for each browser and have UserInfoStorage
use this to store stuff to localStorage
? How would I unit-test this without tying the test for UserInfoStorage
to the implementation of Storage
?
Thanks!