Skip to content

Commit 40f20fd

Browse files
author
Jonathan Hersh
committed
[Tests] Additional coverage
1 parent 4ca6040 commit 40f20fd

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

Example/ExampleSSDataSourcesTests/SSCoreDataSourceTests.m

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Example/ExampleSSDataSourcesTests/SSSectionedDataSourceTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ - (void)test_removing_all_items_in_section
5353
expect(section.items).to.haveCountOf(0);
5454
expect(ds.numberOfSections).to.equal(0);
5555

56-
ds = [[SSSectionedDataSource alloc] initWithItems:@[ @"foo", @"bar", @"baz" ]];
56+
ds = [[SSSectionedDataSource alloc] initWithSections:@[ [SSSection sectionWithItems:@[ @"foo", @"bar", @"baz" ]] ]];
5757
section = [ds sectionAtIndex:0];
5858
expect(section.items).to.haveCountOf(3);
5959
[ds removeItemsInRange:NSMakeRange(0, 3) inSection:0];

0 commit comments

Comments
 (0)