Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 3500efe

Browse files
author
vikasrohit
committed
Merge pull request #470 from appirio-tech/feature/empty-state-directive
SUP-2231, New Empty States for Dashboard and Profile @parthshah fyi, added unit test
2 parents 81c6f0f + d11e59e commit 3500efe

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/* jshint -W117, -W030 */
2+
describe('Empty State Placeholder Directive', function() {
3+
var scope;
4+
var element;
5+
var emptyStateService;
6+
var stateToTest = null;
7+
var stateToTestName = "dashboard-challenges";
8+
9+
beforeEach(function() {
10+
bard.appModule('topcoder');
11+
bard.inject(this, '$compile', '$rootScope', 'EmptyStateService');
12+
emptyStateService = EmptyStateService;
13+
stateToTest = emptyStateService.getState(stateToTestName);
14+
});
15+
16+
bard.verifyNoOutstandingHttpRequests();
17+
18+
describe('Without transcluded content', function() {
19+
var emptyState;
20+
21+
beforeEach(function() {
22+
scope = $rootScope.$new();
23+
scope.show = true;
24+
scope.theme = 'black';
25+
scope.stateName = stateToTestName;
26+
element = angular.element('<empty-state-placeholder state-name="{{stateName}}" theme="{{theme}}" show="show"></empty-state-placeholder>)');
27+
emptyState = $compile(element)(scope);
28+
scope.$digest();
29+
controller = element.controller('emptyStatePlaceholder');
30+
});
31+
32+
it('should have found a valid empty state', function() {
33+
expect(controller.title).to.exist.to.equal(stateToTest.title);
34+
expect(controller.description).to.exist.to.equal(stateToTest.description);
35+
expect(controller.helpLinks).to.exist;
36+
expect(controller.helpLinks.length).to.equal(stateToTest.helpLinks.length);
37+
});
38+
39+
it('should have valid visibilty state', function() {
40+
expect(controller.show).to.exist.to.equal(true);
41+
expect(controller.theme).to.exist.to.equal('black');
42+
});
43+
44+
it('should have valid transcluded state', function() {
45+
expect(element.isolateScope().transcluded).to.exist.to.equal(false);
46+
});
47+
48+
it('should watch changes in show param expression', function() {
49+
expect(controller.show).to.exist.to.equal(true);
50+
// update the show variable expression
51+
scope.show = false;
52+
scope.$digest();
53+
// should update controller's state
54+
expect(controller.show).to.exist.to.equal(false);
55+
});
56+
});
57+
58+
describe('With transcluded content', function() {
59+
var emptyState;
60+
61+
beforeEach(function() {
62+
scope = $rootScope.$new();
63+
scope.show = true;
64+
scope.theme = 'black';
65+
scope.stateName = stateToTestName;
66+
element = angular.element('<empty-state-placeholder state-name="{{stateName}}" theme="{{theme}}" show="show"><span>Test</span></empty-state-placeholder>)');
67+
emptyState = $compile(element)(scope);
68+
scope.$digest();
69+
controller = element.controller('emptyStatePlaceholder');
70+
});
71+
72+
it('should have found a valid empty state', function() {
73+
expect(controller.title).to.exist.to.equal(stateToTest.title);
74+
expect(controller.description).to.exist.to.equal(stateToTest.description);
75+
expect(controller.helpLinks).to.exist;
76+
expect(controller.helpLinks.length).to.equal(stateToTest.helpLinks.length);
77+
});
78+
79+
it('should have valid visibilty state', function() {
80+
expect(controller.show).to.exist.to.equal(true);
81+
expect(controller.theme).to.exist.to.equal('black');
82+
});
83+
84+
it('should have valid transcluded state', function() {
85+
expect(element.isolateScope().transcluded).to.exist.to.equal(true);
86+
});
87+
88+
it('should watch changes in show param expression', function() {
89+
expect(controller.show).to.exist.to.equal(true);
90+
// update the show variable expression
91+
scope.show = false;
92+
scope.$digest();
93+
// should update controller's state
94+
expect(controller.show).to.exist.to.equal(false);
95+
});
96+
});
97+
});

0 commit comments

Comments
 (0)