forked from tabwrangler/tabwrangler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add coverage script in package.json - add more tests - clean up
- Loading branch information
1 parent
3d094c0
commit 3d55d63
Showing
7 changed files
with
242 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/ | ||
node_modules/ | ||
coverage/ | ||
tabwrangler*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import storageLocal from '../app/js/storageLocal'; | ||
|
||
beforeEach(() => { | ||
window.chrome = { | ||
storage: { | ||
local: {}, | ||
onChanged: { | ||
addListener() { | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
afterEach(() => { | ||
window.chrome = {}; | ||
}); | ||
|
||
test('should refresh cache after localstorage changed', () => { | ||
const mockFunctionGet = jest.fn(); | ||
const mockFunctionSet = jest.fn(); | ||
window.chrome.storage.local.set = mockFunctionSet; | ||
window.chrome.storage.local.get = mockFunctionGet; | ||
|
||
// initialize cache and localStarage change listener | ||
storageLocal.init(); | ||
|
||
// update local storage with default entries | ||
expect(Object.keys(storageLocal.cache).length).toBe(4); | ||
|
||
// replace the savedTabs | ||
storageLocal.setValue('savedTabs', [{'test': 'new Value'}]); | ||
|
||
// cache must be updated | ||
expect(Object.keys(storageLocal.cache).length).toBe(5); | ||
expect(storageLocal.cache['savedTabs']).toEqual([{ test: 'new Value' }]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.