@interface-technologies/check-for-js-bundle-update-saga 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@interface-technologies/check-for-js-bundle-update-saga",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.3",
|
4
4
|
"description": "Redux saga for checking if a JavaScript app has been deployed.",
|
5
5
|
"homepage": "https://github.com/srmagura/iti-react",
|
6
6
|
"repository": {
|
@@ -23,8 +23,8 @@
|
|
23
23
|
"redux-saga": "^1.1.3"
|
24
24
|
},
|
25
25
|
"devDependencies": {
|
26
|
-
"@interface-technologies/iti-react": "4.0.
|
27
|
-
"@interface-technologies/tsconfig": "4.0.
|
26
|
+
"@interface-technologies/iti-react": "4.0.3",
|
27
|
+
"@interface-technologies/tsconfig": "4.0.3",
|
28
28
|
"@redux-saga/is": "^1.1.2",
|
29
29
|
"@redux-saga/symbols": "^1.1.2",
|
30
30
|
"@testing-library/react-hooks": "^7.0.2",
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"redux-saga-test-plan": "^4.0.4"
|
33
33
|
},
|
34
34
|
"peerDependencies": {
|
35
|
-
"@interface-technologies/iti-react": "^4.0.
|
35
|
+
"@interface-technologies/iti-react": "^4.0.3",
|
36
36
|
"@popperjs/core": "^2.10.2",
|
37
37
|
"bootstrap": "^5.1.2",
|
38
38
|
"react": "^17.0.2"
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
7
|
-
const redux_saga_test_plan_1 = require("redux-saga-test-plan");
|
8
|
-
const effects_1 = require("redux-saga/effects");
|
9
|
-
const iti_react_1 = require("@interface-technologies/iti-react");
|
10
|
-
const checkForJsBundleUpdateSaga_1 = require("./checkForJsBundleUpdateSaga");
|
11
|
-
jest.mock('@interface-technologies/iti-react');
|
12
|
-
// Mock window.location.reload since it not implemented in jsdom
|
13
|
-
// eslint-disable-next-line
|
14
|
-
delete window.location;
|
15
|
-
window.location = { reload: jest.fn() };
|
16
|
-
const jsBundleHash = 'hash0';
|
17
|
-
const newJsBundleHash = 'hash1';
|
18
|
-
beforeEach(() => {
|
19
|
-
jest.useRealTimers();
|
20
|
-
const script = document.createElement('script');
|
21
|
-
script.src = `app.${jsBundleHash}.js`;
|
22
|
-
document.head.appendChild(script);
|
23
|
-
});
|
24
|
-
function getHtml(hash) {
|
25
|
-
return `
|
26
|
-
<html>
|
27
|
-
<head>
|
28
|
-
<script src="nprogress.min.js"></script>
|
29
|
-
<script defer="defer" src="app.${hash}.js"></script>
|
30
|
-
</head>
|
31
|
-
<body>
|
32
|
-
</body>
|
33
|
-
</html>
|
34
|
-
`;
|
35
|
-
}
|
36
|
-
const delayDuration = moment_timezone_1.default.duration(0, 'seconds');
|
37
|
-
it('does not show alert if hash matches', async () => {
|
38
|
-
const onError = jest.fn();
|
39
|
-
await (0, redux_saga_test_plan_1.expectSaga)(checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga, { delayDuration, onError })
|
40
|
-
.provide([[(0, effects_1.call)(checkForJsBundleUpdateSaga_1.getIndexHtml), getHtml(jsBundleHash)]])
|
41
|
-
.not.call.fn(iti_react_1.alert)
|
42
|
-
.not.call.fn(checkForJsBundleUpdateSaga_1.reload)
|
43
|
-
.silentRun();
|
44
|
-
expect(onError).not.toHaveBeenCalled();
|
45
|
-
});
|
46
|
-
it('does not call onError if getIndexHtml returns undefined', async () => {
|
47
|
-
const onError = jest.fn();
|
48
|
-
await (0, redux_saga_test_plan_1.expectSaga)(checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga, { delayDuration, onError })
|
49
|
-
.provide([[(0, effects_1.call)(checkForJsBundleUpdateSaga_1.getIndexHtml), undefined]])
|
50
|
-
.not.call.fn(iti_react_1.alert)
|
51
|
-
.not.call.fn(checkForJsBundleUpdateSaga_1.reload)
|
52
|
-
.silentRun();
|
53
|
-
expect(onError).not.toHaveBeenCalled();
|
54
|
-
});
|
55
|
-
it('shows alert several times and then refreshes page', async () => {
|
56
|
-
const onError = jest.fn((e) => console.error(e));
|
57
|
-
await (0, redux_saga_test_plan_1.expectSaga)(checkForJsBundleUpdateSaga_1.checkForJsBundleUpdateSaga, { delayDuration, onError })
|
58
|
-
.provide([[(0, effects_1.call)(checkForJsBundleUpdateSaga_1.getIndexHtml), getHtml(newJsBundleHash)]])
|
59
|
-
.call.fn(iti_react_1.alert)
|
60
|
-
.call.fn(iti_react_1.alert)
|
61
|
-
.call.fn(iti_react_1.alert)
|
62
|
-
.call(checkForJsBundleUpdateSaga_1.reload)
|
63
|
-
.run();
|
64
|
-
expect(onError).not.toHaveBeenCalled();
|
65
|
-
expect(window.location.reload).toHaveBeenCalled();
|
66
|
-
});
|