|
| 1 | +describe('Directive: pfCard', function() { |
| 2 | + var $scope, $compile, element, headTitle, subTitle, cardClass, innerContent; |
| 3 | + |
| 4 | + beforeEach(module( |
| 5 | + 'patternfly.card', |
| 6 | + 'card/basic/card.html' |
| 7 | + )); |
| 8 | + |
| 9 | + beforeEach(inject(function(_$compile_, _$rootScope_) { |
| 10 | + $compile = _$compile_; |
| 11 | + $scope = _$rootScope_; |
| 12 | + })); |
| 13 | + |
| 14 | + describe('Page with pf-card directive', function () { |
| 15 | + |
| 16 | + var compileCard = function (markup, scope) { |
| 17 | + var el = $compile(markup)(scope); |
| 18 | + scope.$digest(); |
| 19 | + return el; |
| 20 | + }; |
| 21 | + |
| 22 | + it("should set the headTitle and subTitle and inner content", function() { |
| 23 | + |
| 24 | + element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title">Inner content goes here</div>', $scope); |
| 25 | + |
| 26 | + headTitle = angular.element(element).find('.card-pf-title').html(); |
| 27 | + expect(headTitle).toBe("My card title"); |
| 28 | + |
| 29 | + subTitle = angular.element(element).find('.card-pf-subtitle').html(); |
| 30 | + expect(subTitle).toBe("My card subtitle title"); |
| 31 | + |
| 32 | + innerContent = angular.element(element).find('.card-pf-body span').html(); |
| 33 | + expect(innerContent).toBe("Inner content goes here"); |
| 34 | + |
| 35 | + // By default, showTopBorder if not defined, should be false, resulting in hiding the top |
| 36 | + // border, ie. having a .card-pf class |
| 37 | + cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented'); |
| 38 | + expect(cardClass).toBeFalsy(); |
| 39 | + }); |
| 40 | + |
| 41 | + it("should show the top border", function() { |
| 42 | + |
| 43 | + 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); |
| 44 | + |
| 45 | + // showTopBorder set to true, results in having the .card-pf-accented class |
| 46 | + cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented'); |
| 47 | + expect(cardClass).toBeTruthy(); |
| 48 | + |
| 49 | + }); |
| 50 | + |
| 51 | + it("should hide the top border", function() { |
| 52 | + |
| 53 | + element = compileCard('<div pf-card head-title="My card title" sub-title="My card subtitle title" show-top-border="false">Inner content goes here</div>', $scope); |
| 54 | + |
| 55 | + // showTopBorder set to false, results in not having the .card-pf-accented class |
| 56 | + cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented'); |
| 57 | + expect(cardClass).toBeFalsy(); |
| 58 | + |
| 59 | + }); |
| 60 | + |
| 61 | + }); |
| 62 | +}); |
0 commit comments