|
| 1 | +describe('Component: pfInfoStatusCard', function () { |
| 2 | + var $scope, $compile, element, cardClass |
| 3 | + |
| 4 | + beforeEach(module('patternfly.card', 'card/info-status/info-status-card.html')) |
| 5 | + |
| 6 | + beforeEach(inject(function (_$compile_, _$rootScope_) { |
| 7 | + $compile = _$compile_ |
| 8 | + $scope = _$rootScope_ |
| 9 | + })) |
| 10 | + |
| 11 | + describe('Page with pf-info-status-card component', function () { |
| 12 | + |
| 13 | + var compileCard = function (markup, scope) { |
| 14 | + var el = $compile(markup)(scope) |
| 15 | + scope.$digest() |
| 16 | + return el |
| 17 | + } |
| 18 | + |
| 19 | + it('should set the title link, and icons class', function () { |
| 20 | + |
| 21 | + $scope.status = { |
| 22 | + 'title': 'TinyCore-local', |
| 23 | + 'href': '#', |
| 24 | + 'iconClass': 'fa fa-shield', |
| 25 | + 'info': [ |
| 26 | + 'VM Name: aapdemo002' |
| 27 | + ] |
| 28 | + } |
| 29 | + |
| 30 | + element = compileCard('<pf-info-status-card status="status"></pf-info-status-card>', $scope) |
| 31 | + |
| 32 | + //Make sure a link renders in the title |
| 33 | + expect(angular.element(element).find('.card-pf-title').find('a').length).toBe(1) |
| 34 | + |
| 35 | + //Make sure the class is getting set for the title icon |
| 36 | + expect(angular.element(element).find('.fa').hasClass('fa-shield')).toBeTruthy() |
| 37 | + |
| 38 | + // By default, showTopBorder if not defined, should be false, resulting in hiding the top |
| 39 | + // border, ie. having a .card-pf class |
| 40 | + cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented') |
| 41 | + expect(cardClass).toBeFalsy() |
| 42 | + }) |
| 43 | + |
| 44 | + it('No link should be present in the title', function () { |
| 45 | + |
| 46 | + $scope.status = { |
| 47 | + 'title': 'TinyCore-local', |
| 48 | + 'iconClass': 'fa fa-shield', |
| 49 | + 'info': [ |
| 50 | + 'VM Name: aapdemo002' |
| 51 | + ] |
| 52 | + } |
| 53 | + |
| 54 | + element = compileCard('<pf-info-status-card status="status"></pf-info-status-card>', $scope) |
| 55 | + |
| 56 | + //Make sure a link renders in the title |
| 57 | + expect(angular.element(element).find('.card-pf-title').find('a').length).toBe(0) |
| 58 | + }) |
| 59 | + |
| 60 | + it('should set the info', function () { |
| 61 | + |
| 62 | + $scope.status = { |
| 63 | + 'title': 'TinyCore-local', |
| 64 | + 'href': '#', |
| 65 | + 'iconClass': 'fa fa-shield', |
| 66 | + 'info': [ |
| 67 | + 'VM Name: aapdemo002', |
| 68 | + 'Host Name: localhost.localdomian', |
| 69 | + 'IP Address: 10.9.62.100', |
| 70 | + 'Power status: on' |
| 71 | + ] |
| 72 | + } |
| 73 | + |
| 74 | + element = compileCard('<pf-info-status-card status="status"></pf-info-status-card>', $scope) |
| 75 | + |
| 76 | + info = angular.element(element).find('p') |
| 77 | + |
| 78 | + //Make sure four info blocks render |
| 79 | + expect(info.length).toBe(4) |
| 80 | + }) |
| 81 | + |
| 82 | + it('should show the top border', function () { |
| 83 | + element = compileCard('<pf-info-status-card show-top-border="true"></pf-info-status-card>', $scope) |
| 84 | + |
| 85 | + // showTopBorder set to true, results in having the .card-pf-accented class |
| 86 | + cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented') |
| 87 | + expect(cardClass).toBeTruthy() |
| 88 | + |
| 89 | + }) |
| 90 | + |
| 91 | + it('should hide the top border', function () { |
| 92 | + element = compileCard('<pf-info-status-card show-top-border="false"></pf-info-status-card>', $scope) |
| 93 | + |
| 94 | + // showTopBorder set to false, results in not having the .card-pf-accented class |
| 95 | + cardClass = angular.element(element).find('.card-pf').hasClass('card-pf-accented') |
| 96 | + expect(cardClass).toBeFalsy() |
| 97 | + }) |
| 98 | + |
| 99 | + it('should set of the iconImage value', function () { |
| 100 | + |
| 101 | + $scope.status = { |
| 102 | + 'iconImage': 'img/OpenShift-logo.svg', |
| 103 | + 'info': [ |
| 104 | + 'Infastructure: VMware', |
| 105 | + 'Vmware: 1 CPU (1 socket x 1 core), 1024 MB', |
| 106 | + '12 Snapshots', |
| 107 | + 'Drift History: 1' |
| 108 | + ] |
| 109 | + } |
| 110 | + |
| 111 | + element = compileCard('<pf-info-status-card status="status"></pf-info-status-card>', $scope) |
| 112 | + |
| 113 | + // should have the images |
| 114 | + imageElements = angular.element(element).find('.info-img') |
| 115 | + expect(imageElements.length).toBe(1) |
| 116 | + expect(angular.element(imageElements[0]).attr('src')).toBe('img/OpenShift-logo.svg') |
| 117 | + }) |
| 118 | + }) |
| 119 | +}) |
0 commit comments