@@ -34,113 +34,6 @@ void main() async {
3434 expect (result! .id, 3 );
3535 });
3636
37- // test('withKeyOf', () {
38- // final familias = <Familia>[];
39- // final pairs = <(Person, Person)>[];
40- // container.familia.writeTxn(() {
41- // familias.addAll([
42- // Familia(id: '1', surname: 'Tester 1').saveLocal(),
43- // Familia(id: '2', surname: 'Tester 2').saveLocal(),
44- // Familia(id: '3', surname: 'Tester 3').saveLocal(),
45- // Familia(id: '4', surname: 'Tester 4').saveLocal(),
46- // Familia(id: '5', surname: 'Tester 5').saveLocal()
47- // ]);
48- // // source without ID + destination with ID
49- // pairs.addAll([
50- // (
51- // Person(name: 'Peter', familia: familias[0].asBelongsTo).saveLocal(),
52- // Person(
53- // id: '1',
54- // name: 'Peter Updated',
55- // familia: familias[0].asBelongsTo)
56- // .saveLocal()
57- // ),
58- // // source without ID + destination without ID
59- // (
60- // Person(name: 'Sonya', familia: familias[1].asBelongsTo).saveLocal(),
61- // Person(name: 'Sonya Updated', familia: familias[1].asBelongsTo)
62- // .saveLocal()
63- // ),
64- // // source with ID + destination with same ID
65- // (
66- // Person(id: '2', name: 'Mark', familia: familias[2].asBelongsTo)
67- // .saveLocal(),
68- // Person(
69- // id: '2',
70- // name: 'Mark Updated',
71- // familia: familias[2].asBelongsTo)
72- // .saveLocal()
73- // ),
74- // // source with ID + destination with different ID
75- // (
76- // Person(id: '3', name: 'Daniel', familia: familias[3].asBelongsTo)
77- // .saveLocal(),
78- // Person(
79- // id: '4',
80- // name: 'Daniel Updated',
81- // familia: familias[3].asBelongsTo)
82- // .saveLocal()
83- // ),
84- // // source with ID + destination without ID
85- // (
86- // Person(id: '5', name: 'Peter', familia: familias[4].asBelongsTo)
87- // .saveLocal(),
88- // Person(name: 'Peter Updated', familia: familias[4].asBelongsTo)
89- // .saveLocal()
90- // ),
91- // ]);
92- // });
93-
94- // for (final pair in pairs) {
95- // final index = pairs.indexOf(pair);
96- // // we receive an update from the server,
97- // // gets initialized with a new key destination
98- // final source = pair.$1;
99- // final destination = pair.$2;
100-
101- // final destKeyBefore = keyFor(destination);
102-
103- // destination.withKeyOf(source);
104-
105- // // now both objects have the same key
106- // expect(keyFor(source), keyFor(destination));
107-
108- // if (destination.id != null) {
109- // // now the source key is associated to id=destination.id
110- // expect(core.getKeyForId('people', destination.id), keyFor(source));
111- // }
112- // expect(destination.familia.value, familias[index]);
113-
114- // if (keyFor(source) != keyFor(destination)) {
115- // expect(core.getIdForKey(destKeyBefore), isNull);
116- // }
117- // }
118-
119- // // test freezed copyWith with different IDs
120- // final house = House(address: '123 Main St').saveLocal();
121- // final b1 =
122- // Book(id: 1, house: house.asBelongsTo, ardentSupporters: HasMany())
123- // .saveLocal();
124- // final b2 = b1.copyWith(id: 2);
125- // // TODO check - copyWith mutates b1 relationships, so we need to save b2 to persist rels
126- // b2.saveLocal();
127- // b2.withKeyOf(b1);
128-
129- // expect(keyFor(b1), keyFor(b2));
130- // expect(b2.house?.value, house);
131-
132- // // test library using DataModelMixin (that can be uninitialized)
133- // final sourceLibrary = Library(id: 1, name: 'one', books: HasMany());
134- // final destinationLibrary = Library(id: 2, name: 'two', books: HasMany());
135-
136- // expect(() => destinationLibrary.withKeyOf(sourceLibrary), throwsException);
137-
138- // final initializedSourceLibrary = sourceLibrary.init();
139- // destinationLibrary.withKeyOf(initializedSourceLibrary);
140- // expect(DataModelMixin.keyFor(initializedSourceLibrary),
141- // DataModelMixin.keyFor(destinationLibrary));
142- // });
143-
14437 test ('findOne (remote and local reload)' , () async {
14538 var familia = await Familia (id: '1' , surname: 'Perez' ).save ();
14639 familia = Familia (id: '1' , surname: 'Perez Gomez' );
0 commit comments