|
490 | 490 | });
|
491 | 491 | });
|
492 | 492 |
|
| 493 | +describe(@"-branches:", ^{ |
| 494 | + __block NSArray *branches; |
| 495 | + |
| 496 | + beforeEach(^{ |
| 497 | + GTRepository *repository = [self testAppForkFixtureRepository]; |
| 498 | + branches = [repository branches:NULL]; |
| 499 | + expect(branches).notTo(beNil()); |
| 500 | + }); |
| 501 | + |
| 502 | + it(@"should combine a local branch with its remote branch", ^{ |
| 503 | + NSMutableArray *localBranchAs = [NSMutableArray array]; |
| 504 | + NSMutableArray *remoteBranchAs = [NSMutableArray array]; |
| 505 | + for (GTBranch *branch in branches) { |
| 506 | + if ([branch.shortName isEqual:@"BranchA"]) { |
| 507 | + if (branch.branchType == GTBranchTypeLocal) { |
| 508 | + [localBranchAs addObject:branch]; |
| 509 | + } else { |
| 510 | + [remoteBranchAs addObject:branch]; |
| 511 | + } |
| 512 | + } |
| 513 | + } |
| 514 | + |
| 515 | + expect(@(localBranchAs.count)).to(equal(@1)); |
| 516 | + |
| 517 | + GTBranch *localBranchA = localBranchAs[0]; |
| 518 | + GTBranch *trackingBranch = [localBranchA trackingBranchWithError:NULL success:NULL]; |
| 519 | + expect(trackingBranch.remoteName).to(equal(@"origin")); |
| 520 | + |
| 521 | + expect(@(remoteBranchAs.count)).to(equal(@1)); |
| 522 | + |
| 523 | + GTBranch *remoteBranchA = remoteBranchAs[0]; |
| 524 | + expect(remoteBranchA.remoteName).to(equal(@"github")); |
| 525 | + }); |
| 526 | + |
| 527 | + it(@"should contain local branches", ^{ |
| 528 | + NSInteger index = [branches indexOfObjectPassingTest:^BOOL(GTBranch *branch, NSUInteger idx, BOOL *stop) { |
| 529 | + return [branch.shortName isEqual:@"new-shite"]; |
| 530 | + }]; |
| 531 | + expect(@(index)).notTo(equal(@(NSNotFound))); |
| 532 | + }); |
| 533 | + |
| 534 | + it(@"should contain remote branches which exist on multiple remotes", ^{ |
| 535 | + NSUInteger matches = 0; |
| 536 | + for (GTBranch *branch in branches) { |
| 537 | + if ([branch.shortName isEqual:@"blah"] && branch.branchType == GTBranchTypeRemote) { |
| 538 | + matches++; |
| 539 | + } |
| 540 | + } |
| 541 | + expect(@(matches)).to(equal(@2)); |
| 542 | + }); |
| 543 | +}); |
| 544 | + |
493 | 545 | afterEach(^{
|
494 | 546 | [self tearDown];
|
495 | 547 | });
|
|
0 commit comments