sdc_client 0.158.6 → 0.158.7
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/dist/index.js +6 -6
- package/dist/ugly.index.js +1 -1
- package/gulp/gulp.jsx +2 -1
- package/package.json +1 -1
- package/src/simpleDomControl/AbstractSDC.js +9 -0
- package/src/simpleDomControl/sdc_model.js +117 -50
- package/src/simpleDomControl/sdc_params.js +20 -62
- package/src/simpleDomControl/sdc_server_call.js +1 -1
- package/src/simpleDomControl/sdc_test_utils.js +4 -2
- package/src/simpleDomControl/sdc_view.js +9 -4
- package/test/model.test.js +8 -10
- package/test/models/Author.js +1 -1
- package/test/models/Book.js +1 -1
- package/test/models/BookContent.js +1 -1
- package/test/models/SdcUser.js +1 -1
- package/test/utils.js +4 -5
- package/test/view.test.js +1 -0
package/test/model.test.js
CHANGED
|
@@ -38,16 +38,16 @@ class MockModelSocketServer {
|
|
|
38
38
|
constructor() {
|
|
39
39
|
this.records = {
|
|
40
40
|
Author: [
|
|
41
|
-
{
|
|
42
|
-
{
|
|
41
|
+
{ id: 1, pk: 1, fields: {name: "Ada Lovelace", age: 36, book_set: [11]} },
|
|
42
|
+
{ id: 2, pk: 2, fields: {name: "Grace Hopper", age: 85, book_set: [21, 22]} },
|
|
43
43
|
],
|
|
44
44
|
Book: [
|
|
45
|
-
{
|
|
46
|
-
{
|
|
47
|
-
{
|
|
45
|
+
{ id: 11, pk: 11, fields: {title: "Notes", author: 1 }},
|
|
46
|
+
{ id: 21, pk: 21, fields: {title: "Compiler Notes", author: 2 }},
|
|
47
|
+
{ id: 22, pk: 22, fields: {title: "COBOL", author: 2 }},
|
|
48
48
|
],
|
|
49
49
|
BookContent: [],
|
|
50
|
-
SdcUser: [{
|
|
50
|
+
SdcUser: [{ id: 7, pk: 7, fields: {username: "tester" }}],
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -111,7 +111,7 @@ class MockModelSocketServer {
|
|
|
111
111
|
|
|
112
112
|
saveRow(modelName, data) {
|
|
113
113
|
const records = this.records[modelName];
|
|
114
|
-
const id = data.
|
|
114
|
+
const id = data.id ?? data.id;
|
|
115
115
|
const idx = records.findIndex((row) => row.id === id);
|
|
116
116
|
|
|
117
117
|
records[idx].fields = {
|
|
@@ -294,12 +294,10 @@ describe("model fixtures", () => {
|
|
|
294
294
|
expect(books.socket.sentMessages.at(-1)).toMatchObject({
|
|
295
295
|
event_type: "save",
|
|
296
296
|
args: {
|
|
297
|
-
pk: 21,
|
|
298
297
|
data: {
|
|
299
298
|
id: 21,
|
|
300
299
|
title: "Compiler Notes Revised",
|
|
301
|
-
author: 2
|
|
302
|
-
pk: 21,
|
|
300
|
+
author: 2
|
|
303
301
|
},
|
|
304
302
|
},
|
|
305
303
|
});
|
package/test/models/Author.js
CHANGED
package/test/models/Book.js
CHANGED
package/test/models/SdcUser.js
CHANGED
package/test/utils.js
CHANGED
|
@@ -39,9 +39,6 @@ export class TestCtrA extends AbstractSDC {
|
|
|
39
39
|
sayB() {
|
|
40
40
|
return 'B'
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
onInit() {
|
|
44
|
-
}
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
export class TestList extends AbstractSDC {
|
|
@@ -52,11 +49,12 @@ export class TestList extends AbstractSDC {
|
|
|
52
49
|
this.number = 0;
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
onInit(number = 10) {
|
|
52
|
+
onInit({ number = 10 }) {
|
|
56
53
|
this.number = number;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
56
|
onLoad(html) {
|
|
57
|
+
this.onInit(this.params)
|
|
60
58
|
$(html).append('<div><this.listview></this.listview></div>');
|
|
61
59
|
return super.onLoad(html);
|
|
62
60
|
}
|
|
@@ -78,11 +76,12 @@ export class TestItem extends AbstractSDC {
|
|
|
78
76
|
this.events.unshift({});
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
onInit(idx) {
|
|
79
|
+
onInit({ idx }) {
|
|
82
80
|
this.idx = idx;
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
onLoad(html) {
|
|
84
|
+
this.onInit(this.params);
|
|
86
85
|
$(html).append(`<input name="i_${this.idx}" />`);
|
|
87
86
|
return super.onLoad(html);
|
|
88
87
|
}
|
package/test/view.test.js
CHANGED
|
@@ -149,6 +149,7 @@ describe('Controller reconcile', () => {
|
|
|
149
149
|
await new Promise((resolve) => setTimeout(resolve, 1000))
|
|
150
150
|
const newList = $('body').find('input').toArray();
|
|
151
151
|
expect(newList.length).toBe(5);
|
|
152
|
+
|
|
152
153
|
newList.forEach((x, i) => {
|
|
153
154
|
expect(x).toBe(oldList[i]);
|
|
154
155
|
});
|