Skip to content

Commit 5d99685

Browse files
committed
Convert card unit tests to new component style
1 parent a67adda commit 5d99685

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

test/card/aggregate-status/aggregate-status-card.directive.spec.js renamed to test/card/aggregate-status/aggregate-status-card.component.spec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('Directive: pfAggregateStatusCard', function() {
1+
describe('Component: pfAggregateStatusCard', function() {
22
var $scope, $compile, element, cardClass, notifications;
33

44
beforeEach(module('patternfly.card', 'card/aggregate-status/aggregate-status-card.html'));
@@ -8,7 +8,7 @@ describe('Directive: pfAggregateStatusCard', function() {
88
$scope = _$rootScope_;
99
}));
1010

11-
describe('Page with pf-aggregate-status-card directive', function () {
11+
describe('Page with pf-aggregate-status-card component', function () {
1212

1313
var compileCard = function (markup, scope) {
1414
var el = $compile(markup)(scope);
@@ -25,7 +25,7 @@ describe('Directive: pfAggregateStatusCard', function() {
2525
"iconClass": "fa fa-shield",
2626
};
2727

28-
element = compileCard('<div pf-aggregate-status-card status="status"></div>', $scope);
28+
element = compileCard('<pf-aggregate-status-card status="status"></pf-aggregate-status-card>', $scope);
2929

3030
//Make sure the count is getting set properly in the title
3131
expect(angular.element(element).find('.card-pf-aggregate-status-count').html()).toBe("793");
@@ -50,7 +50,7 @@ describe('Directive: pfAggregateStatusCard', function() {
5050
"iconClass": "fa fa-shield"
5151
};
5252

53-
element = compileCard('<div pf-aggregate-status-card status="status"></div>', $scope);
53+
element = compileCard('<pf-aggregate-status-card status="status"></pf-aggregate-status-card>', $scope);
5454

5555
//Make sure a link renders in the title
5656
expect(angular.element(element).find('.card-pf-title').find('a').size()).toBe(0);
@@ -76,7 +76,7 @@ describe('Directive: pfAggregateStatusCard', function() {
7676
]
7777
};
7878

79-
element = compileCard('<div pf-aggregate-status-card status="status"></div>', $scope);
79+
element = compileCard('<pf-aggregate-status-card status="status"></pf-aggregate-status-card>', $scope);
8080

8181
notifications = angular.element(element).find('.card-pf-aggregate-status-notification');
8282

@@ -97,7 +97,7 @@ describe('Directive: pfAggregateStatusCard', function() {
9797
});
9898

9999
it("should show the top border", function() {
100-
element = compileCard('<div pf-aggregate-status-card show-top-border="true"></div>', $scope);
100+
element = compileCard('<pf-aggregate-status-card show-top-border="true"></pf-aggregate-status-card>', $scope);
101101

102102
// showTopBorder set to true, results in having the .card-pf-accented class
103103
cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented');
@@ -106,7 +106,7 @@ describe('Directive: pfAggregateStatusCard', function() {
106106
});
107107

108108
it("should hide the top border", function() {
109-
element = compileCard('<div pf-aggregate-status-card show-top-border="false"></div>', $scope);
109+
element = compileCard('<pf-aggregate-status-card show-top-border="false"></pf-aggregate-status-card>', $scope);
110110

111111
// showTopBorder set to false, results in not having the .card-pf-accented class
112112
cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented');
@@ -127,7 +127,7 @@ describe('Directive: pfAggregateStatusCard', function() {
127127
}
128128
};
129129

130-
element = compileCard('<div pf-aggregate-status-card status="status" layout="mini"></div>', $scope);
130+
element = compileCard('<pf-aggregate-status-card status="status" layout="mini"></pf-aggregate-status-card>', $scope);
131131

132132
// should have the mini layout class
133133
cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-aggregate-status-mini');
@@ -158,7 +158,7 @@ describe('Directive: pfAggregateStatusCard', function() {
158158
}
159159
};
160160

161-
element = compileCard('<div pf-aggregate-status-card status="status" layout="mini"></div>', $scope);
161+
element = compileCard('<pf-aggregate-status-card status="status" layout="mini"></pf-aggregate-status-card>', $scope);
162162

163163
// should have the mini layout class
164164
cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-aggregate-status-mini');
@@ -186,7 +186,7 @@ describe('Directive: pfAggregateStatusCard', function() {
186186
}
187187
};
188188

189-
element = compileCard('<div pf-aggregate-status-card status="status" layout="mini"></div>', $scope);
189+
element = compileCard('<pf-aggregate-status-card status="status" layout="mini"></pf-aggregate-status-card>', $scope);
190190

191191
notifications = angular.element(element).find('.card-pf-aggregate-status-notification');
192192

@@ -215,7 +215,7 @@ describe('Directive: pfAggregateStatusCard', function() {
215215
]
216216
};
217217

218-
element = compileCard('<div pf-aggregate-status-card status="aggStatusAlt" layout="tall"></div>', $scope);
218+
element = compileCard('<pf-aggregate-status-card status="aggStatusAlt" layout="tall"></pf-aggregate-status-card>', $scope);
219219

220220
// should have the images
221221
imageElements = angular.element(element).find('.card-pf-icon-image');

test/card/basic/card.spec.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe('Directive: pfCard', function() {
1+
describe('Component: pfCard', function() {
22
var $scope, $compile, element, headTitle, subTitle, cardClass, innerContent, isoScope;
33

44
beforeEach(module(
@@ -12,18 +12,18 @@ describe('Directive: pfCard', function() {
1212
$scope = _$rootScope_;
1313
}));
1414

15-
describe('Page with pf-card directive', function () {
15+
describe('Page with pf-card component', function () {
1616

1717
var compileCard = function (markup, scope) {
1818
var el = $compile(markup)(scope);
1919
scope.$digest();
20-
isoScope = el.isolateScope();
20+
isoScope = el.controller("pf-card");
2121
return el;
2222
};
2323

2424
it("should set the headTitle and subTitle and inner content", function() {
2525

26-
element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title"><span>Inner content goes here</span></div>', $scope);
26+
element = compileCard('<pf-card head-title="My card title" sub-title="My card subtitle title"><span>Inner content goes here</span></pf-card>', $scope);
2727

2828
headTitle = angular.element(element).find('.card-pf-title').html();
2929
expect(headTitle).toBe("My card title");
@@ -42,7 +42,7 @@ describe('Directive: pfCard', function() {
4242

4343
it("should show the top border", function() {
4444

45-
element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title" show-top-border="true">Inner content goes here</div>', $scope);
45+
element = compileCard('<pf-card head-title="My card title" sub-title="My card subtitle title" show-top-border="true">Inner content goes here</pf-card>', $scope);
4646

4747
// showTopBorder set to true, results in having the .card-pf-accented class
4848
cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented');
@@ -63,21 +63,21 @@ describe('Directive: pfCard', function() {
6363
it("should show and hide the bottom border", function() {
6464

6565
// by default, bottom border should be shown
66-
element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title">Inner content goes here</div>', $scope);
66+
element = compileCard('<pf-card head-title="My card title" sub-title="My card subtitle title">Inner content goes here</pf-card>', $scope);
6767
cardClass = angular.element(element).find('.card-pf-heading');
6868
expect(cardClass.size()).toBe(1);
6969
cardClass = angular.element(element).find('.card-pf-heading-no-bottom');
7070
expect(cardClass.size()).toBe(0);
7171

7272
// setting to false should hide the bottom border
73-
element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title" show-titles-separator="false">Inner content goes here</div>', $scope);
73+
element = compileCard('<pf-card head-title="My card title" sub-title="My card subtitle title" show-titles-separator="false">Inner content goes here</pf-card>', $scope);
7474
cardClass = angular.element(element).find('.card-pf-heading');
7575
expect(cardClass.size()).toBe(0);
7676
cardClass = angular.element(element).find('.card-pf-heading-no-bottom');
7777
expect(cardClass.size()).toBe(1);
7878

7979
// setting to true should show the bottom border
80-
element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title" show-titles-separator="true">Inner content goes here</div>', $scope);
80+
element = compileCard('<pf-card head-title="My card title" sub-title="My card subtitle title" show-titles-separator="true">Inner content goes here</pf-card>', $scope);
8181
cardClass = angular.element(element).find('.card-pf-heading');
8282
expect(cardClass.size()).toBe(1);
8383
cardClass = angular.element(element).find('.card-pf-heading-no-bottom');
@@ -88,7 +88,7 @@ describe('Directive: pfCard', function() {
8888
it("should hide the action bar footer by default", function() {
8989

9090
// by default, if footer not defined, footer should not be shown
91-
element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title">Inner content goes here</div>', $scope);
91+
element = compileCard('<pf-card head-title="My card title" sub-title="My card subtitle title">Inner content goes here</pf-card>', $scope);
9292
cardClass = angular.element(element).find('.card-pf-footer');
9393
expect(cardClass.size()).toBe(0);
9494
});
@@ -102,7 +102,7 @@ describe('Directive: pfCard', function() {
102102
'text' : 'Add New Cluster'
103103
};
104104

105-
element = compileCard('<div pf-card head-title="title" footer="actionBarConfig">Inner content</div>', $scope);
105+
element = compileCard('<pf-card head-title="title" footer="actionBarConfig">Inner content</pf-card>', $scope);
106106
cardClass = angular.element(element).find('a');
107107
expect(cardClass.attr('href')).toBe('#addCluster');
108108
var spans = cardClass.find('span');
@@ -119,7 +119,7 @@ describe('Directive: pfCard', function() {
119119
}
120120
};
121121

122-
element = compileCard('<div pf-card head-title="title" footer="actionBarConfig">Inner content</div>', $scope);
122+
element = compileCard('<pf-card head-title="title" footer="actionBarConfig">Inner content</pf-card>', $scope);
123123
cardClass = angular.element(element).find('a');
124124
expect(cardClass.attr('href')).toBeUndefined();
125125

@@ -143,7 +143,7 @@ describe('Directive: pfCard', function() {
143143
'text' : 'Add New Cluster'
144144
};
145145

146-
element = compileCard('<div pf-card head-title="title" footer="actionBarConfig">Inner content</div>', $scope);
146+
element = compileCard('<pf-card head-title="title" footer="actionBarConfig">Inner content</pf-card>', $scope);
147147
cardClass = angular.element(element).find('.card-pf-footer').find('button');
148148
expect(cardClass.size()).toBe(0);
149149
});
@@ -160,7 +160,7 @@ describe('Directive: pfCard', function() {
160160
'defaultFilter' : 2
161161
};
162162

163-
element = compileCard('<div pf-card head-title="title" footer="{}" filter="filterConfig">Inner content</div>', $scope);
163+
element = compileCard('<pf-card head-title="title" footer="{}" filter="filterConfig">Inner content</pf-card>', $scope);
164164

165165
// should find 3 filters
166166
cardClass = angular.element(element).find('.card-pf-footer').find('a');
@@ -192,7 +192,7 @@ describe('Directive: pfCard', function() {
192192
'position' : 'header'
193193
};
194194

195-
element = compileCard('<div pf-card head-title="title" footer="{}" filter="filterConfig">Inner content</div>', $scope);
195+
element = compileCard('<pf-card pf-card head-title="title" footer="{}" filter="filterConfig">Inner content</pf-card>', $scope);
196196

197197
// should NOT find any filters in the footer
198198
cardClass = angular.element(element).find('.card-pf-footer').find('a');
@@ -217,7 +217,7 @@ describe('Directive: pfCard', function() {
217217

218218
it("should not show the header if no title or filter specified", function() {
219219

220-
element = compileCard('<div pf-card>Inner content</div>', $scope);
220+
element = compileCard('<pf-card>Inner content</pf-card>', $scope);
221221

222222
// should NOT find any header artifacts
223223
cardClass = angular.element(element).find('.card-pf-heading');

0 commit comments

Comments
 (0)