@@ -102,11 +102,39 @@ - (void)testInsertingItemInsertsRow
102102 [[mockTable expect ] insertRowsAtIndexPaths: @[ [NSIndexPath indexPathForRow: 0 inSection: 0 ] ]
103103 withRowAnimation: animation];
104104
105- [Wizard wizardWithName: @" Gandalf" realm: @" Middle-Earth" inContext: [NSManagedObjectContext MR_defaultContext ]];
105+ [MagicalRecord saveWithBlockAndWait: ^(NSManagedObjectContext *context) {
106+ [Wizard wizardWithName: @" Gandalf" realm: @" Middle-Earth" inContext: context];
107+ }];
106108
107- [[NSManagedObjectContext MR_defaultContext ] MR_saveToPersistentStoreAndWait ];
109+ [mockTable verifyWithDelay: 1 ];
110+ }
111+
112+ - (void )testUpdatingItemMovesRow
113+ {
114+ id mockTable = tableView;
108115
109- [mockTable verify ];
116+ UITableViewRowAnimation animation = UITableViewRowAnimationLeft;
117+
118+ dataSource.rowAnimation = animation;
119+
120+ [MagicalRecord saveWithBlockAndWait: ^(NSManagedObjectContext *context) {
121+ [Wizard wizardWithName: @" Gandalf" realm: @" Middle-Earth" inContext: context];
122+ [Wizard wizardWithName: @" Pallando" realm: @" Middle-Earth" inContext: context];
123+ }];
124+
125+ expect ([dataSource numberOfItems ]).will .equal (2 );
126+
127+ [[mockTable expect ] deleteRowsAtIndexPaths: @[ [NSIndexPath indexPathForRow: 0 inSection: 0 ] ]
128+ withRowAnimation: animation];
129+ [[mockTable expect ] insertRowsAtIndexPaths: @[ [NSIndexPath indexPathForRow: 1 inSection: 0 ] ]
130+ withRowAnimation: animation];
131+
132+ [MagicalRecord saveWithBlockAndWait: ^(NSManagedObjectContext *context) {
133+ Wizard *w = [Wizard MR_findFirstByAttribute: @" name" withValue: @" Gandalf" inContext: context];
134+ w.name = @" ZGandalf" ;
135+ }];
136+
137+ [mockTable verifyWithDelay: 1 ];
110138}
111139
112140- (void )testInsertingItemInsertsRowInCollectionView
0 commit comments