Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test($breadcrumb): add test cases for different values of `prefixStat…
…eName`
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*jshint undef: false */ | ||
|
||
describe('Service with basic conf', function() { | ||
|
||
describe('and prefix option setted to a root state', function() { | ||
beforeEach(function() { | ||
angular.module('ncy-basic-conf') | ||
.config(function($breadcrumbProvider) { | ||
$breadcrumbProvider.setOptions({ | ||
prefixStateName: 'A' | ||
}); | ||
}); | ||
module('ncy-basic-conf'); | ||
}); | ||
|
||
it('should have a 3-step route to C state', inject(function($breadcrumb) { | ||
goToState('A.B.C'); | ||
var statesChain = $breadcrumb.getStatesChain(); | ||
expect(stringifyStateChain(statesChain)).toBe('A --> A.B --> A.B.C'); | ||
})); | ||
|
||
it('should return only the prefix state for skipped G', inject(function($breadcrumb) { | ||
goToState('G'); | ||
var statesChain = $breadcrumb.getStatesChain(); | ||
expect(stringifyStateChain(statesChain)).toBe('A'); | ||
})); | ||
|
||
it('should return a 2-step chain to G.H', inject(function($breadcrumb) { | ||
goToState('G.H'); | ||
var statesChain = $breadcrumb.getStatesChain(); | ||
expect(stringifyStateChain(statesChain)).toBe('A --> G.H'); | ||
})); | ||
}); | ||
|
||
describe('and prefix option setted to an intermediate state', function() { | ||
beforeEach(function() { | ||
angular.module('ncy-basic-conf') | ||
.config(function($breadcrumbProvider) { | ||
$breadcrumbProvider.setOptions({ | ||
prefixStateName: 'A.B' | ||
}); | ||
}); | ||
module('ncy-basic-conf'); | ||
}); | ||
|
||
it('should have a 3-step route to C state', inject(function($breadcrumb) { | ||
goToState('A.B.C'); | ||
var statesChain = $breadcrumb.getStatesChain(); | ||
expect(stringifyStateChain(statesChain)).toBe('A.B --> A --> A.B.C'); | ||
})); | ||
|
||
it('should return only the prefix state for skipped G', inject(function($breadcrumb) { | ||
goToState('G'); | ||
var statesChain = $breadcrumb.getStatesChain(); | ||
expect(stringifyStateChain(statesChain)).toBe('A.B'); | ||
})); | ||
|
||
it('should return a 2-step chain to G.H', inject(function($breadcrumb) { | ||
goToState('G.H'); | ||
var statesChain = $breadcrumb.getStatesChain(); | ||
expect(stringifyStateChain(statesChain)).toBe('A.B --> G.H'); | ||
})); | ||
}); | ||
|
||
|
||
|
||
}); |