|
| 1 | +describe('Directive: pfApplicationLauncher', function () { |
| 2 | + |
| 3 | + var $scope; |
| 4 | + var $compile; |
| 5 | + var element; |
| 6 | + var isolateScope; |
| 7 | + |
| 8 | + // load the controller's module |
| 9 | + beforeEach(function () { |
| 10 | + module('patternfly.navigation', 'patternfly.utils', 'navigation/application-launcher.html'); |
| 11 | + }); |
| 12 | + |
| 13 | + beforeEach(inject(function (_$compile_, _$rootScope_) { |
| 14 | + $compile = _$compile_; |
| 15 | + $scope = _$rootScope_; |
| 16 | + })); |
| 17 | + |
| 18 | + var compileHTML = function (markup, scope) { |
| 19 | + element = angular.element(markup); |
| 20 | + $compile(element)(scope); |
| 21 | + |
| 22 | + scope.$digest(); |
| 23 | + isolateScope = element.isolateScope(); |
| 24 | + }; |
| 25 | + |
| 26 | + beforeEach(function () { |
| 27 | + $scope.sites = [ |
| 28 | + { |
| 29 | + title: "Recteque", |
| 30 | + href: "#/ipsum/intellegam/recteque", |
| 31 | + tooltip: "Total number of error items", |
| 32 | + iconClass: "" |
| 33 | + }, |
| 34 | + { |
| 35 | + title: "Suavitate", |
| 36 | + href: "#/ipsum/intellegam/suavitate", |
| 37 | + tooltip: "Total number of items", |
| 38 | + iconClass: "" |
| 39 | + } |
| 40 | + ]; |
| 41 | + }); |
| 42 | + |
| 43 | + it('should have menu items', function () { |
| 44 | + var htmlTmp = '<div pf-application-launcher items="sites" label="" is-disabled="false" is-list="false"></div>'; |
| 45 | + compileHTML(htmlTmp, $scope); |
| 46 | + |
| 47 | + var content = element.find('[role="menuitem"]'); |
| 48 | + expect(content.length).toBe(2); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should have a custom label', function () { |
| 52 | + var htmlTmp = '<div pf-application-launcher items="sites" label="Product Launcher" is-disabled="true" is-list="false" hidden-icons="false"></div>'; |
| 53 | + compileHTML(htmlTmp, $scope); |
| 54 | + |
| 55 | + var content = element.find('[id*="domain-switcher"]').text(); |
| 56 | + expect(content).toContain('Product Launcher'); |
| 57 | + }); |
| 58 | + |
| 59 | + it('should be disabled', function () { |
| 60 | + var htmlTmp = '<div pf-application-launcher items="sites" label="" is-disabled="true" is-list="false" hidden-icons="false"></div>'; |
| 61 | + compileHTML(htmlTmp, $scope); |
| 62 | + |
| 63 | + var content = element.find('[id*="domain-switcher"].disabled'); |
| 64 | + expect(content.length).toBe(1); |
| 65 | + }); |
| 66 | + |
| 67 | + it('should be displayed as a list', function () { |
| 68 | + var htmlTmp = '<div pf-application-launcher items="sites" label="" is-disabled="false" is-list="true" hidden-icons="false"></div>'; |
| 69 | + compileHTML(htmlTmp, $scope); |
| 70 | + |
| 71 | + var content = element.find('.applauncher-pf-block-list'); |
| 72 | + expect(content.length).toBe(0); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should have hidden application icons', function () { |
| 76 | + var htmlTmp = '<div pf-application-launcher items="sites" label="" is-disabled="false" is-list="true" hidden-icons="true"></div>'; |
| 77 | + compileHTML(htmlTmp, $scope); |
| 78 | + |
| 79 | + var content = element.find('.applauncher-pf-link-icon'); |
| 80 | + expect(content.length).toBe(0); |
| 81 | + }); |
| 82 | + |
| 83 | +}); |
| 84 | + |
0 commit comments