Skip to content

Commit

Permalink
test($breadcrumb): add test cases for different values of `prefixStat…
Browse files Browse the repository at this point in the history
…eName`
  • Loading branch information
ncuillery committed Jun 26, 2014
1 parent 2ab7ced commit 9040764
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions test/spec/service-prefix-test.js
@@ -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');
}));
});



});

0 comments on commit 9040764

Please sign in to comment.