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.
@@ -38,16 +38,16 @@ class MockModelSocketServer {
38
38
  constructor() {
39
39
  this.records = {
40
40
  Author: [
41
- { pk: 1, id: 1, fields: {name: "Ada Lovelace", age: 36, book_set: [11]} },
42
- { pk: 2, id: 2, fields: {name: "Grace Hopper", age: 85, book_set: [21, 22]} },
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
- { pk: 11, id: 11, fields: {title: "Notes", author: 1 }},
46
- { pk: 21, id: 21, fields: {title: "Compiler Notes", author: 2 }},
47
- { pk: 22, id: 22, fields: {title: "COBOL", author: 2 }},
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: [{ pk: 7, id: 7, fields: {username: "tester" }}],
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.pk ?? data.id;
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
  });
@@ -66,7 +66,7 @@ export default class Author extends SdcModel {
66
66
  }
67
67
 
68
68
  setValues(data = {}) {
69
- data.id ??= data.pk ?? null;
69
+ data.id ??= data.id ?? null;
70
70
  try {
71
71
  this.book_set.setFilter({ author: data.id });
72
72
  this.book_set = data.book_set || [];
@@ -52,7 +52,7 @@ export default class Book extends SdcModel {
52
52
  }
53
53
 
54
54
  setValues(data = {}) {
55
- data.id ??= data.pk ?? null;
55
+ data.id ??= data.id ?? null;
56
56
  try {
57
57
  this.id = data.id ?? null;
58
58
  } catch {}
@@ -54,7 +54,7 @@ export default class BookContent extends SdcModel {
54
54
  }
55
55
 
56
56
  setValues(data = {}) {
57
- data.id ??= data.pk ?? null;
57
+ data.id ??= data.id ?? null;
58
58
  try {
59
59
  this.id = data.id ?? null;
60
60
  } catch {}
@@ -38,7 +38,7 @@ export default class SdcUser extends SdcModel {
38
38
 
39
39
  setValues(data = {}) {
40
40
  try {
41
- this.id = data.id ?? data.pk ?? null;
41
+ this.id = data.id ?? data.id ?? null;
42
42
  } catch {}
43
43
  try {
44
44
  this.username = data.username ?? null;
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
  });