Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Commit

Permalink
Added tests to make sure that action names given to grouping methods …
Browse files Browse the repository at this point in the history
…override any that are set within the grouping itself
  • Loading branch information
jspahrsummers committed Apr 13, 2012
1 parent afed3ac commit 137c528
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions ProtonTests/PRONSUndoManagerAdditionsTests.m
Expand Up @@ -47,9 +47,19 @@ - (void)decrementChangeCountWithUndoManager:(NSUndoManager *)undoManager;
describe(@"adding grouping using block", ^{
it(@"should set action name", ^{
[undoManager addGroupingWithActionName:@"foobar" usingBlock:^{
expect(weakManager.undoActionName).toEqual(@"foobar");
return YES;
}];

expect(undoManager.undoActionName).toEqual(@"foobar");
});

it(@"should override any action name set within the block", ^{
[undoManager addGroupingWithActionName:@"foobar" usingBlock:^{
undoManager.actionName = @"fuzzbuzz";
return YES;
}];

expect(undoManager.undoActionName).toEqual(@"foobar");
});

it(@"should create nested group", ^{
Expand Down Expand Up @@ -455,7 +465,7 @@ - (void)decrementChangeCountWithUndoManager:(NSUndoManager *)undoManager;
expect(calledUndoWithBlock).toBeTruthy();
});

it(@"opens an edit grouping without a name", ^{
it(@"opens an edit grouping", ^{
BOOL success = [undoManager tryEditGrouping];
expect(success).toBeTruthy();

Expand All @@ -464,6 +474,17 @@ - (void)decrementChangeCountWithUndoManager:(NSUndoManager *)undoManager;
[undoManager endEditGrouping];
});

it(@"overrides names set within an edit grouping block", ^{
NSString *expectedName = @"foobar";
BOOL success = [undoManager tryEditGroupingWithActionName:expectedName usingBlock:^{
block();
undoManager.actionName = @"fuzzbuzz";
}];

expect(success).toBeTruthy();
expect(undoManager.undoActionName).toEqual(expectedName);
});

describe(@"with an open edit grouping", ^{
before(^{
BOOL success = [undoManager tryEditGrouping];
Expand Down Expand Up @@ -496,12 +517,10 @@ - (void)decrementChangeCountWithUndoManager:(NSUndoManager *)undoManager;

describe(@"with a block", ^{
before(^{
BOOL success = [undoManager tryEditGroupingWithActionName:@"foobar" usingBlock:^{
expect(undoManager.undoActionName).toEqual(@"foobar");
block();
}];

BOOL success = [undoManager tryEditGroupingWithActionName:@"foobar" usingBlock:block];
expect(success).toBeTruthy();

expect(undoManager.undoActionName).toEqual(@"foobar");
expect(calledBlock).toBeTruthy();
});

Expand Down

0 comments on commit 137c528

Please sign in to comment.