import { ItemCollectionMock } from "../xrm-mock/collection/itemcollection/itemcollection.mock" ; import { ITabComponents } from "../xrm-mock/controls/tab/tab.mock" ; import { UiCanGetVisibleElementMock } from "../xrm-mock/controls/uicangetvisibleelement/uicangetvisibleelement.mock" ; import { UiLabelElementMock } from "../xrm-mock/controls/uilabelelement/uilabelelement.mock" ; import { UiStandardElementMock } from "../xrm-mock/controls/uistandardelement/uistandardelement.mock" ; import * as XrmMock from "../xrm-mock/index" ; import ControlHelpers from "./helpers/control.helper" ; export default class Tab { param { string } name param { string } label param { boolean } isVisible param { Xrm . DisplayState } displayState param { Xrm . ui } parent param { Xrm . Collection . ItemCollection < Xrm . Controls . Section > } sections returns { XrmMock . TabMock } memberof public createTab ( name ? , label ? , isVisible ? , displayState ? , parent ? , sections ? ) { const tabs = Xrm . Page . ui . tabs as ItemCollectionMock < Xrm . Controls . Tab > ; if ( ! tabs ) { throw new Error ( `Couldn't find the tabs collection in the XRM object.` ) ; } const tabComponents = { displayState , name , parent : parent || Xrm . Page . ui , sections , uiStandardElement : new UiStandardElementMock ( new UiLabelElementMock ( label ) , new UiCanGetVisibleElementMock ( isVisible ) ) , } ; const tab = new XrmMock . TabMock ( tabComponents ) ; if ( sections ) { ControlHelpers . setControlsParent ( sections , tab ) ; } tabs . push ( tab ) ; return tab ; } }