Check caches and delete the expire ones only on install. This should hopefully speed up the service worker a bit.
I used service-worker-mock package to test the install event handler and I want to refactor a lot of the tests to use this instead of karma, keeping only a few as integration tests running in an actual browser - but that's for a different PR
PR is a bit difficult to read because of linting changes as well - my bad. Basically:
helpers.js -> helpers-browser.js
helpers.js now holds a purgeCache function.
Changed import cache from 'cache' to const cache = require('cache') to be able to mock and test functions properly
__sw.spec.js is the main addition.
Refactored the last test in cache.spec.js to use the new checkAndExpireAllCaches function.
Check caches and delete the expire ones only on install. This should hopefully speed up the service worker a bit.
I used service-worker-mock package to test the
install
event handler and I want to refactor a lot of the tests to use this instead of karma, keeping only a few as integration tests running in an actual browser - but that's for a different PRPR is a bit difficult to read because of linting changes as well - my bad. Basically:
import cache from 'cache'
toconst cache = require('cache')
to be able to mock and test functions properlycheckAndExpireAllCaches
function.