@entropic-bond/crud-panel 3.3.3 → 3.4.1
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/lib/crud-controller.js +73 -150
- package/lib/crud-controller.js.map +1 -1
- package/lib/crud-controller.spec.js +44 -129
- package/lib/crud-controller.spec.js.map +1 -1
- package/lib/crud-panel.js +74 -155
- package/lib/crud-panel.js.map +1 -1
- package/lib/crud-panel.spec.js +174 -364
- package/lib/crud-panel.spec.js.map +1 -1
- package/lib/progress-controller.js +13 -15
- package/lib/progress-controller.js.map +1 -1
- package/lib/progress-controller.spec.js +32 -32
- package/lib/progress-controller.spec.js.map +1 -1
- package/package.json +14 -13
package/lib/crud-controller.js
CHANGED
|
@@ -8,178 +8,101 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.CrudController = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
const entropic_bond_1 = require("entropic-bond");
|
|
14
|
+
const progress_controller_1 = require("./progress-controller");
|
|
15
|
+
class CrudController {
|
|
16
|
+
constructor(document) {
|
|
44
17
|
this.progressController = new progress_controller_1.ProgressController();
|
|
45
18
|
this.onChangeHdl = new entropic_bond_1.Observable();
|
|
46
19
|
this.setDocument(document || this.createDocument());
|
|
47
20
|
}
|
|
48
|
-
|
|
21
|
+
storeDoc() {
|
|
49
22
|
return this.model.save(this.document);
|
|
50
|
-
}
|
|
51
|
-
|
|
23
|
+
}
|
|
24
|
+
deleteDoc() {
|
|
52
25
|
return this.model.delete(this.document.id);
|
|
53
|
-
}
|
|
54
|
-
|
|
26
|
+
}
|
|
27
|
+
findDocs(limit) {
|
|
55
28
|
return this.model.find().limit(limit).get();
|
|
56
|
-
}
|
|
57
|
-
|
|
29
|
+
}
|
|
30
|
+
onChange(observer) {
|
|
58
31
|
return this.onChangeHdl.subscribe(observer);
|
|
59
|
-
}
|
|
60
|
-
|
|
32
|
+
}
|
|
33
|
+
notifyChange(event) {
|
|
61
34
|
this.onChangeHdl.notify(event);
|
|
62
|
-
}
|
|
63
|
-
|
|
35
|
+
}
|
|
36
|
+
newDocument() {
|
|
64
37
|
return this.setDocument(this.createDocument());
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_d.sent();
|
|
81
|
-
_b = (_a = this.onChangeHdl).notify;
|
|
82
|
-
_c = {};
|
|
83
|
-
return [4 /*yield*/, this.documentCollection()];
|
|
84
|
-
case 3:
|
|
85
|
-
_b.apply(_a, [(_c.documentCollection = _d.sent(),
|
|
86
|
-
_c.action = 'saved',
|
|
87
|
-
_c)]);
|
|
88
|
-
return [3 /*break*/, 5];
|
|
89
|
-
case 4:
|
|
90
|
-
this.progressController.notifyBusy(false, progressStage);
|
|
91
|
-
return [7 /*endfinally*/];
|
|
92
|
-
case 5: return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
38
|
+
}
|
|
39
|
+
storeDocument() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const progressStage = 'Saving main document';
|
|
42
|
+
try {
|
|
43
|
+
this.progressController.notifyBusy(true, progressStage);
|
|
44
|
+
yield this.storeDoc();
|
|
45
|
+
this.onChangeHdl.notify({
|
|
46
|
+
documentCollection: yield this.documentCollection(),
|
|
47
|
+
action: 'saved'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
this.progressController.notifyBusy(false, progressStage);
|
|
52
|
+
}
|
|
95
53
|
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
_d.sent();
|
|
112
|
-
_b = (_a = this.onChangeHdl).notify;
|
|
113
|
-
_c = {};
|
|
114
|
-
return [4 /*yield*/, this.documentCollection()];
|
|
115
|
-
case 3:
|
|
116
|
-
_b.apply(_a, [(_c.documentCollection = _d.sent(),
|
|
117
|
-
_c.action = 'deleted',
|
|
118
|
-
_c)]);
|
|
119
|
-
return [3 /*break*/, 5];
|
|
120
|
-
case 4:
|
|
121
|
-
this.progressController.notifyBusy(false, progressStage);
|
|
122
|
-
return [7 /*endfinally*/];
|
|
123
|
-
case 5: return [2 /*return*/];
|
|
124
|
-
}
|
|
125
|
-
});
|
|
54
|
+
}
|
|
55
|
+
deleteDocument() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const progressStage = 'Delete main document';
|
|
58
|
+
try {
|
|
59
|
+
this.progressController.notifyBusy(true, progressStage);
|
|
60
|
+
yield this.deleteDoc();
|
|
61
|
+
this.onChangeHdl.notify({
|
|
62
|
+
documentCollection: yield this.documentCollection(),
|
|
63
|
+
action: 'deleted'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
this.progressController.notifyBusy(false, progressStage);
|
|
68
|
+
}
|
|
126
69
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return [4 /*yield*/, this.findDocs(limit)];
|
|
140
|
-
case 2:
|
|
141
|
-
found = _a.sent();
|
|
142
|
-
return [3 /*break*/, 4];
|
|
143
|
-
case 3:
|
|
144
|
-
this.progressController.notifyBusy(false, progressStage);
|
|
145
|
-
return [7 /*endfinally*/];
|
|
146
|
-
case 4: return [2 /*return*/, found];
|
|
147
|
-
}
|
|
148
|
-
});
|
|
70
|
+
}
|
|
71
|
+
documentCollection(limit) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const progressStage = 'Retrieving document collection';
|
|
74
|
+
try {
|
|
75
|
+
this.progressController.notifyBusy(true, progressStage);
|
|
76
|
+
var found = yield this.findDocs(limit);
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
this.progressController.notifyBusy(false, progressStage);
|
|
80
|
+
}
|
|
81
|
+
return found;
|
|
149
82
|
});
|
|
150
|
-
}
|
|
151
|
-
|
|
83
|
+
}
|
|
84
|
+
onProgress(observer) {
|
|
152
85
|
return this.progressController.onProgress(observer);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
enumerable: false,
|
|
159
|
-
configurable: true
|
|
160
|
-
});
|
|
161
|
-
CrudController.prototype.setDocument = function (value) {
|
|
162
|
-
var _this = this;
|
|
86
|
+
}
|
|
87
|
+
get model() {
|
|
88
|
+
return this._model || (this._model = this.getModel());
|
|
89
|
+
}
|
|
90
|
+
setDocument(value) {
|
|
163
91
|
if (this._document !== value) {
|
|
164
92
|
if (this.unsubscribeDocument)
|
|
165
93
|
this.unsubscribeDocument();
|
|
166
|
-
this.unsubscribeDocument = value.onChange(
|
|
94
|
+
this.unsubscribeDocument = value.onChange(e => this.onChangeHdl.notify({ documentProps: e }));
|
|
167
95
|
this._document = value;
|
|
168
96
|
this.onChangeHdl.notify({ documentChanged: this._document });
|
|
169
97
|
}
|
|
170
98
|
return this;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
enumerable: false,
|
|
180
|
-
configurable: true
|
|
181
|
-
});
|
|
182
|
-
return CrudController;
|
|
183
|
-
}());
|
|
99
|
+
}
|
|
100
|
+
set document(value) {
|
|
101
|
+
this.setDocument(value);
|
|
102
|
+
}
|
|
103
|
+
get document() {
|
|
104
|
+
return this._document;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
184
107
|
exports.CrudController = CrudController;
|
|
185
108
|
//# sourceMappingURL=crud-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud-controller.js","sourceRoot":"","sources":["../src/crud-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crud-controller.js","sourceRoot":"","sources":["../src/crud-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA6G;AAC7G,+DAAyE;AAWzE,MAAsB,cAAc;IACnC,YAAa,QAAY;QA0Gf,uBAAkB,GAAuB,IAAI,wCAAkB,EAAE,CAAA;QACjE,gBAAW,GAAuC,IAAI,0BAAU,EAA0B,CAAA;QA1GnG,IAAI,CAAC,WAAW,CAAE,QAAQ,IAAI,IAAI,CAAC,cAAc,EAAE,CAAE,CAAA;IACtD,CAAC;IAMS,QAAQ;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,IAAI,CAAC,QAAQ,CAAE,CAAA;IACxC,CAAC;IAES,SAAS;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAE,CAAA;IAC7C,CAAC;IAES,QAAQ,CAAE,KAAa;QAChC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAE,KAAK,CAAE,CAAC,GAAG,EAAE,CAAA;IAC9C,CAAC;IAED,QAAQ,CAAE,QAA0C;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAE,QAAQ,CAAE,CAAA;IAC9C,CAAC;I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ics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
29
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -40,38 +14,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
40
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
15
|
});
|
|
42
16
|
};
|
|
43
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
44
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
45
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
46
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
47
|
-
function step(op) {
|
|
48
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
49
|
-
while (_) try {
|
|
50
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
51
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
52
|
-
switch (op[0]) {
|
|
53
|
-
case 0: case 1: t = op; break;
|
|
54
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
55
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
56
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
57
|
-
default:
|
|
58
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
59
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
60
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
61
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
62
|
-
if (t[2]) _.ops.pop();
|
|
63
|
-
_.trys.pop(); continue;
|
|
64
|
-
}
|
|
65
|
-
op = body.call(thisArg, _);
|
|
66
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
67
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
18
|
exports.TestController = exports.Test = void 0;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
19
|
+
const entropic_bond_1 = require("entropic-bond");
|
|
20
|
+
const crud_controller_1 = require("./crud-controller");
|
|
21
|
+
const mockData = {
|
|
75
22
|
Test: {
|
|
76
23
|
test1: {
|
|
77
24
|
__className: 'Test',
|
|
@@ -85,92 +32,60 @@ var mockData = {
|
|
|
85
32
|
}
|
|
86
33
|
}
|
|
87
34
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
|
+
let Test = class Test extends entropic_bond_1.EntropicComponent {
|
|
36
|
+
set testProp(value) {
|
|
37
|
+
this.changeProp('testProp', value);
|
|
92
38
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return this._testProp;
|
|
96
|
-
},
|
|
97
|
-
set: function (value) {
|
|
98
|
-
this.changeProp('testProp', value);
|
|
99
|
-
},
|
|
100
|
-
enumerable: false,
|
|
101
|
-
configurable: true
|
|
102
|
-
});
|
|
103
|
-
__decorate([
|
|
104
|
-
entropic_bond_1.persistent
|
|
105
|
-
], Test.prototype, "_testProp", void 0);
|
|
106
|
-
Test = __decorate([
|
|
107
|
-
(0, entropic_bond_1.registerPersistentClass)('Test')
|
|
108
|
-
], Test);
|
|
109
|
-
return Test;
|
|
110
|
-
}(entropic_bond_1.EntropicComponent));
|
|
111
|
-
exports.Test = Test;
|
|
112
|
-
var TestController = /** @class */ (function (_super) {
|
|
113
|
-
__extends(TestController, _super);
|
|
114
|
-
function TestController() {
|
|
115
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
39
|
+
get testProp() {
|
|
40
|
+
return this._testProp;
|
|
116
41
|
}
|
|
117
|
-
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
entropic_bond_1.persistent
|
|
45
|
+
], Test.prototype, "_testProp", void 0);
|
|
46
|
+
Test = __decorate([
|
|
47
|
+
(0, entropic_bond_1.registerPersistentClass)('Test')
|
|
48
|
+
], Test);
|
|
49
|
+
exports.Test = Test;
|
|
50
|
+
class TestController extends crud_controller_1.CrudController {
|
|
51
|
+
createDocument() {
|
|
118
52
|
return new Test();
|
|
119
|
-
}
|
|
120
|
-
|
|
53
|
+
}
|
|
54
|
+
getModel() {
|
|
121
55
|
return entropic_bond_1.Store.getModel('Test');
|
|
122
|
-
}
|
|
123
|
-
|
|
56
|
+
}
|
|
57
|
+
allRequiredPropertiesFilled() {
|
|
124
58
|
return true;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
}(crud_controller_1.CrudController));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
128
61
|
exports.TestController = TestController;
|
|
129
|
-
describe('Crud Controller',
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
beforeEach(
|
|
134
|
-
datasource = new entropic_bond_1.JsonDataSource(
|
|
62
|
+
describe('Crud Controller', () => {
|
|
63
|
+
let controller;
|
|
64
|
+
let datasource;
|
|
65
|
+
let onProgress;
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
datasource = new entropic_bond_1.JsonDataSource(Object.assign({}, mockData));
|
|
135
68
|
entropic_bond_1.Store.useDataSource(datasource);
|
|
136
69
|
controller = new TestController();
|
|
137
70
|
onProgress = jest.fn();
|
|
138
71
|
controller.onProgress(onProgress);
|
|
139
72
|
});
|
|
140
|
-
describe('Long operations',
|
|
141
|
-
beforeEach(
|
|
73
|
+
describe('Long operations', () => {
|
|
74
|
+
beforeEach(() => {
|
|
142
75
|
datasource.simulateDelay(50);
|
|
143
76
|
});
|
|
144
|
-
it('should notify busy on delete',
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}); });
|
|
159
|
-
it('should notify busy on store', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
160
|
-
var promise;
|
|
161
|
-
return __generator(this, function (_a) {
|
|
162
|
-
switch (_a.label) {
|
|
163
|
-
case 0:
|
|
164
|
-
promise = controller.storeDocument();
|
|
165
|
-
expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
|
|
166
|
-
return [4 /*yield*/, promise];
|
|
167
|
-
case 1:
|
|
168
|
-
_a.sent();
|
|
169
|
-
expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
|
|
170
|
-
return [2 /*return*/];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}); });
|
|
77
|
+
it('should notify busy on delete', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
const promise = controller.deleteDocument();
|
|
79
|
+
expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
|
|
80
|
+
yield promise;
|
|
81
|
+
expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
|
|
82
|
+
}));
|
|
83
|
+
it('should notify busy on store', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const promise = controller.storeDocument();
|
|
85
|
+
expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: true }));
|
|
86
|
+
yield promise;
|
|
87
|
+
expect(onProgress).toHaveBeenLastCalledWith(expect.objectContaining({ busy: false }));
|
|
88
|
+
}));
|
|
174
89
|
});
|
|
175
90
|
});
|
|
176
91
|
//# sourceMappingURL=crud-controller.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud-controller.spec.js","sourceRoot":"","sources":["../src/crud-controller.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crud-controller.spec.js","sourceRoot":"","sources":["../src/crud-controller.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,iDAAoH;AACpH,uDAAkD;AAElD,MAAM,QAAQ,GAAG;IAChB,IAAI,EAAE;QACL,KAAK,EAAC;YACL,WAAW,EAAE,MAAM;YACnB,EAAE,EAAE,OAAO;YACX,QAAQ,EAAE,aAAa;SACvB;QACD,KAAK,E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