diff --git a/packages/oui-header-tabs/README.md b/packages/oui-header-tabs/README.md index 5ce82047..48098a2f 100644 --- a/packages/oui-header-tabs/README.md +++ b/packages/oui-header-tabs/README.md @@ -84,6 +84,19 @@ ``` + +### With action click + +```html:preview + + + + + + + +``` + ## API ### oui-header-tabs-item @@ -97,6 +110,7 @@ | `active` | boolean | + ng-if="!!$ctrl.href && !$ctrl.disabled" + ng-click="$ctrl.onClick()"> diff --git a/packages/oui-header-tabs/src/index.spec.js b/packages/oui-header-tabs/src/index.spec.js index e74d02f5..311850e5 100644 --- a/packages/oui-header-tabs/src/index.spec.js +++ b/packages/oui-header-tabs/src/index.spec.js @@ -126,5 +126,21 @@ describe("ouiHeaderTabs", () => { expect($separator.hasClass("oui-dropdown-menu__divider")).toBe(true); expect($separator.attr("role")).toBe("separator"); }); + + it("should call function of onClick attribute, when header tab item is clicked", () => { + const clickSpy = jasmine.createSpy("spy"); + const element = TestUtils.compileTemplate(` + + + `, { + clickHandler: clickSpy + } + ); + + const item = element[0].querySelector(".oui-header-tabs__item a"); + angular.element(item).triggerHandler("click"); + expect(clickSpy).toHaveBeenCalled(); + expect(clickSpy.calls.count()).toEqual(1); + }); }); });