New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dhis2/app-service-offline

Package Overview
Dependencies
Maintainers
14
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dhis2/app-service-offline - npm Package Compare versions

Comparing version 2.10.0-pwa.2 to 2.10.0-pwa.3

28

build/cjs/lib/__tests__/use-cacheable-section.test.js

@@ -199,2 +199,30 @@ "use strict";

expect(result.current.lastUpdated).toBeUndefined();
});
it('handles a change in ID', async () => {
const testOfflineInterface = { ..._testMocks.mockOfflineInterface,
getCachedSections: jest.fn().mockResolvedValue([{
sectionId: 'id-one',
lastUpdated: new Date()
}])
};
const {
result,
waitFor,
rerender
} = (0, _reactHooks.renderHook)((...args) => (0, _cacheableSection.useCacheableSection)(...args), {
wrapper: ({
children
}) => /*#__PURE__*/_react.default.createElement(_offlineProvider.OfflineProvider, {
offlineInterface: testOfflineInterface
}, children),
initialProps: 'id-one'
}); // Wait for state to sync with indexedDB
await waitFor(() => result.current.isCached === true);
rerender('id-two'); // Test that 'isCached' gets updated
// expect(testOfflineInterface.getCachedSections).toBeCalledTimes(2)
await waitFor(() => result.current.isCached === false);
expect(result.current.isCached).toBe(false);
expect(result.current.lastUpdated).toBeUndefined();
});

6

build/cjs/lib/global-state-service.js

@@ -78,5 +78,7 @@ "use strict";

store.subscribe(callback);
store.subscribe(callback); // Make sure to update state when selector changes
callback(store.getState());
return () => store.unsubscribe(callback);
}, [store]);
}, [store, selector]);
/* eslint-disable-line react-hooks/exhaustive-deps */

@@ -83,0 +85,0 @@

@@ -190,2 +190,30 @@ /* eslint-disable react/display-name, react/prop-types */

expect(result.current.lastUpdated).toBeUndefined();
});
it('handles a change in ID', async () => {
const testOfflineInterface = { ...mockOfflineInterface,
getCachedSections: jest.fn().mockResolvedValue([{
sectionId: 'id-one',
lastUpdated: new Date()
}])
};
const {
result,
waitFor,
rerender
} = renderHook((...args) => useCacheableSection(...args), {
wrapper: ({
children
}) => /*#__PURE__*/React.createElement(OfflineProvider, {
offlineInterface: testOfflineInterface
}, children),
initialProps: 'id-one'
}); // Wait for state to sync with indexedDB
await waitFor(() => result.current.isCached === true);
rerender('id-two'); // Test that 'isCached' gets updated
// expect(testOfflineInterface.getCachedSections).toBeCalledTimes(2)
await waitFor(() => result.current.isCached === false);
expect(result.current.isCached).toBe(false);
expect(result.current.lastUpdated).toBeUndefined();
});

@@ -56,5 +56,7 @@ import isEqual from 'lodash/isEqual';

store.subscribe(callback);
store.subscribe(callback); // Make sure to update state when selector changes
callback(store.getState());
return () => store.unsubscribe(callback);
}, [store]);
}, [store, selector]);
/* eslint-disable-line react-hooks/exhaustive-deps */

@@ -61,0 +63,0 @@

{
"name": "@dhis2/app-service-offline",
"description": "A runtime service for online/offline detection and offline caching",
"version": "2.10.0-pwa.2",
"version": "2.10.0-pwa.3",
"main": "./build/cjs/index.js",

@@ -36,3 +36,3 @@ "module": "./build/es/index.js",

"peerDependencies": {
"@dhis2/app-service-alerts": "^2.10.0-pwa.2",
"@dhis2/app-service-alerts": "^2.10.0-pwa.3",
"prop-types": "^15.7.2",

@@ -39,0 +39,0 @@ "react": "^16.8.6",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc