@nuskin/foundation-ui-components 1.33.0-1253-feature.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1221 -0
- package/dist/index.d.ts +1221 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -10
- package/src/common/accordion/NsAccordion.tsx +0 -82
- package/src/common/accordion/NsAccordionHeader.tsx +0 -85
- package/src/common/accordion/NsAccordionItem.tsx +0 -65
- package/src/common/accordion/NsCollapse.tsx +0 -121
- package/src/common/accordion/NsToggleSection.tsx +0 -50
- package/src/common/accordion/ToggleSection.styled.tsx +0 -32
- package/src/common/accordion/colorMap.ts +0 -60
- package/src/common/accordion/enums.ts +0 -18
- package/src/common/accordion/index.ts +0 -7
- package/src/common/accordion/specs/NsAccordion.spec.tsx +0 -183
- package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +0 -172
- package/src/common/accordion/specs/NsAccordionItem.spec.tsx +0 -79
- package/src/common/accordion/specs/NsCollapse.spec.tsx +0 -130
- package/src/common/accordion/specs/NsToggleSection.spec.tsx +0 -74
- package/src/common/accordion/stories/NsAccordion.stories.tsx +0 -65
- package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +0 -44
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +0 -48
- package/src/common/accordion/stories/NsCollapse.stories.tsx +0 -53
- package/src/common/accordion/stories/NsToggleSection.stories.tsx +0 -27
- package/src/common/accordion/stories/data.tsx +0 -145
- package/src/common/accordion/types.d.ts +0 -90
- package/src/common/alert/Header.tsx +0 -29
- package/src/common/alert/NsAlert.spec.tsx +0 -167
- package/src/common/alert/NsAlert.stories.tsx +0 -45
- package/src/common/alert/NsAlert.styled.tsx +0 -114
- package/src/common/alert/NsAlert.tsx +0 -93
- package/src/common/alert/index.ts +0 -2
- package/src/common/alert/types.d.ts +0 -45
- package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +0 -54
- package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +0 -25
- package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +0 -120
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +0 -72
- package/src/common/auth-dropdown/index.ts +0 -2
- package/src/common/auth-dropdown/types.d.ts +0 -11
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +0 -91
- package/src/common/autocomplete/NsAutocomplete.styled.tsx +0 -24
- package/src/common/autocomplete/NsAutocomplete.tsx +0 -225
- package/src/common/autocomplete/helper/LineLoader.tsx +0 -38
- package/src/common/autocomplete/helper/RecentClearAll.tsx +0 -43
- package/src/common/autocomplete/helper/SeeMoreButton.tsx +0 -68
- package/src/common/autocomplete/helper/index.ts +0 -4
- package/src/common/autocomplete/helper/renderGroupName.tsx +0 -26
- package/src/common/autocomplete/index.ts +0 -2
- package/src/common/autocomplete/mock/Mock.styled.tsx +0 -23
- package/src/common/autocomplete/mock/MockData.ts +0 -89
- package/src/common/autocomplete/mock/MockUI.tsx +0 -26
- package/src/common/autocomplete/stories/NoCloseAutoComplete.tsx +0 -49
- package/src/common/autocomplete/stories/NsAutocomplete.stories.tsx +0 -78
- package/src/common/autocomplete/stories/RenderAutoComplete.tsx +0 -60
- package/src/common/autocomplete/types.d.ts +0 -67
- package/src/common/banner/NsBanner.spec.tsx +0 -28
- package/src/common/banner/NsBanner.stories.tsx +0 -47
- package/src/common/banner/NsBanner.styled.tsx +0 -24
- package/src/common/banner/NsBanner.tsx +0 -32
- package/src/common/banner/index.ts +0 -2
- package/src/common/banner/types.d.ts +0 -14
- package/src/common/brand-components/NsBrand.stories.tsx +0 -26
- package/src/common/brand-components/NsBrandComponent.spec.tsx +0 -47
- package/src/common/brand-components/NsBrandComponent.tsx +0 -33
- package/src/common/brand-components/NsBrandContainer.styled.tsx +0 -10
- package/src/common/brand-components/icons/Logo.spec.tsx +0 -84
- package/src/common/brand-components/icons/NSLogoHorizontal.tsx +0 -70
- package/src/common/brand-components/icons/NSLogoMark.tsx +0 -39
- package/src/common/brand-components/icons/NSLogoPoweredBy.tsx +0 -103
- package/src/common/brand-components/icons/NSLogoStacked.tsx +0 -57
- package/src/common/brand-components/icons/NSWordMark.tsx +0 -60
- package/src/common/brand-components/index.ts +0 -2
- package/src/common/brand-components/types.d.ts +0 -11
- package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +0 -28
- package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +0 -39
- package/src/common/breadcrumb/NsBreadcrumb.styled.tsx +0 -36
- package/src/common/breadcrumb/NsBreadcrumb.tsx +0 -85
- package/src/common/breadcrumb/data.ts +0 -10
- package/src/common/breadcrumb/index.ts +0 -2
- package/src/common/breadcrumb/types.d.ts +0 -14
- package/src/common/button/NsButton.spec.tsx +0 -94
- package/src/common/button/NsButton.stories.tsx +0 -118
- package/src/common/button/NsButton.styled.tsx +0 -57
- package/src/common/button/NsButton.tsx +0 -48
- package/src/common/button/__snapshots__/NsButton.spec.tsx.snap +0 -120
- package/src/common/button/helper.ts +0 -84
- package/src/common/button/index.ts +0 -2
- package/src/common/button/types.d.ts +0 -26
- package/src/common/card/CardButton.tsx +0 -58
- package/src/common/card/NsAwardCard.tsx +0 -71
- package/src/common/card/NsBgCard.tsx +0 -26
- package/src/common/card/NsBrandCard.tsx +0 -88
- package/src/common/card/NsBrandLogo.tsx +0 -16
- package/src/common/card/NsBrandWrapper.tsx +0 -25
- package/src/common/card/NsCheckoutCard.tsx +0 -107
- package/src/common/card/NsHeroCardLevel1.tsx +0 -105
- package/src/common/card/NsHeroCardLevel2.tsx +0 -95
- package/src/common/card/NsIconText.tsx +0 -165
- package/src/common/card/NsLargeCard.tsx +0 -108
- package/src/common/card/NsMediumCard.tsx +0 -110
- package/src/common/card/NsPost.tsx +0 -78
- package/src/common/card/NsSmallFullCard.tsx +0 -93
- package/src/common/card/NsXLargeCard.tsx +0 -89
- package/src/common/card/cardSizes.ts +0 -12
- package/src/common/card/fixtures/ImageData1.ts +0 -38
- package/src/common/card/fixtures/ImageData2.ts +0 -38
- package/src/common/card/index.ts +0 -15
- package/src/common/card/specs/BrandLogo.spec.tsx +0 -13
- package/src/common/card/specs/NsAwardCard.spec.tsx +0 -29
- package/src/common/card/specs/NsBgCard.spec.tsx +0 -23
- package/src/common/card/specs/NsBrandCard.spec.tsx +0 -84
- package/src/common/card/specs/NsCheckoutCard.spec.tsx +0 -39
- package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +0 -39
- package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +0 -49
- package/src/common/card/specs/NsIconText.spec.tsx +0 -25
- package/src/common/card/specs/NsLargeCard.spec.tsx +0 -47
- package/src/common/card/specs/NsMediumCard.spec.tsx +0 -51
- package/src/common/card/specs/NsPost.spec.tsx +0 -28
- package/src/common/card/specs/NsSmallFullCard.spec.tsx +0 -47
- package/src/common/card/specs/NsXLargeCard.spec.tsx +0 -47
- package/src/common/card/stories/NsAwardCard.stories.tsx +0 -21
- package/src/common/card/stories/NsBrandCard.stories.tsx +0 -32
- package/src/common/card/stories/NsCheckoutCard.stories.tsx +0 -23
- package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +0 -30
- package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +0 -29
- package/src/common/card/stories/NsIconText.stories.tsx +0 -18
- package/src/common/card/stories/NsLargeCard.stories.tsx +0 -32
- package/src/common/card/stories/NsMediumCard.stories.tsx +0 -34
- package/src/common/card/stories/NsPost.stories.tsx +0 -20
- package/src/common/card/stories/NsSmallFullCard.stories.tsx +0 -31
- package/src/common/card/stories/NsXLargeCard.stories.tsx +0 -32
- package/src/common/card/stories/data.ts +0 -43
- package/src/common/card/types.d.ts +0 -25
- package/src/common/carousal/CarousalControl.tsx +0 -47
- package/src/common/carousal/IconWrapper.tsx +0 -33
- package/src/common/carousal/NsCarousal.tsx +0 -65
- package/src/common/carousal/NsScrollingCarousal.tsx +0 -60
- package/src/common/carousal/RenderBrand.tsx +0 -20
- package/src/common/carousal/index.ts +0 -5
- package/src/common/carousal/slickSetting.ts +0 -61
- package/src/common/carousal/specs/Chevron.spec.tsx +0 -10
- package/src/common/carousal/specs/NsCarousal.spec.tsx +0 -112
- package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +0 -63
- package/src/common/carousal/specs/RenderBrand.spec.tsx +0 -22
- package/src/common/carousal/stories/NsCarousal1.stories.tsx +0 -34
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +0 -80
- package/src/common/carousal/types.d.ts +0 -23
- package/src/common/cart-icon/NsCartIcon.spec.tsx +0 -19
- package/src/common/cart-icon/NsCartIcon.stories.tsx +0 -28
- package/src/common/cart-icon/NsCartIcon.styled.tsx +0 -15
- package/src/common/cart-icon/NsCartIcon.tsx +0 -24
- package/src/common/cart-icon/index.ts +0 -2
- package/src/common/cart-icon/types.d.ts +0 -8
- package/src/common/checkbox/NsCheckbox.spec.tsx +0 -57
- package/src/common/checkbox/NsCheckbox.stories.tsx +0 -55
- package/src/common/checkbox/NsCheckbox.styled.tsx +0 -55
- package/src/common/checkbox/NsCheckbox.tsx +0 -68
- package/src/common/checkbox/index.ts +0 -2
- package/src/common/checkbox/types.d.ts +0 -20
- package/src/common/column-control/NsColumnControl.tsx +0 -64
- package/src/common/column-control/NsFlexColumns.tsx +0 -29
- package/src/common/column-control/NsGridColumns.tsx +0 -29
- package/src/common/column-control/index.ts +0 -4
- package/src/common/column-control/specs/NsColumnControl.spec.tsx +0 -24
- package/src/common/column-control/specs/NsFlexColumns.spec.tsx +0 -24
- package/src/common/column-control/specs/NsGridColumns.spec.tsx +0 -24
- package/src/common/column-control/stories/DivArray.stories.tsx +0 -18
- package/src/common/column-control/stories/DivArray.tsx +0 -63
- package/src/common/column-control/stories/NsColumnControl.stories.tsx +0 -65
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +0 -66
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +0 -75
- package/src/common/column-control/stories/common.tsx +0 -14
- package/src/common/column-control/styled/StyledFlex.tsx +0 -46
- package/src/common/column-control/styled/StyledGrid.tsx +0 -41
- package/src/common/column-control/styled/common.ts +0 -27
- package/src/common/column-control/types.d.ts +0 -46
- package/src/common/column-control/utils.ts +0 -66
- package/src/common/common.types.d.ts +0 -21
- package/src/common/dropdown/NsDropdown.spec.tsx +0 -126
- package/src/common/dropdown/NsDropdown.styled.tsx +0 -66
- package/src/common/dropdown/NsDropdown.tsx +0 -94
- package/src/common/dropdown/NsDropdownOption.tsx +0 -13
- package/src/common/dropdown/index.ts +0 -3
- package/src/common/dropdown/stories/NsDropdown.stories.tsx +0 -67
- package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +0 -64
- package/src/common/dropdown/types.d.ts +0 -23
- package/src/common/email-simple/NsEmailSimple.spec.tsx +0 -115
- package/src/common/email-simple/NsEmailSimple.stories.tsx +0 -61
- package/src/common/email-simple/NsEmailSimple.tsx +0 -72
- package/src/common/email-simple/index.ts +0 -2
- package/src/common/email-simple/types.d.ts +0 -14
- package/src/common/flag/NsFlag.spec.tsx +0 -27
- package/src/common/flag/NsFlag.stories.tsx +0 -22
- package/src/common/flag/NsFlag.styled.tsx +0 -73
- package/src/common/flag/NsFlag.tsx +0 -24
- package/src/common/flag/index.ts +0 -2
- package/src/common/flag/types.d.ts +0 -16
- package/src/common/hooks/index.ts +0 -2
- package/src/common/hooks/specs/useWindowSize.spec.tsx +0 -19
- package/src/common/hooks/useAccordionMap.tsx +0 -39
- package/src/common/hooks/useOnClickOutside.tsx +0 -25
- package/src/common/hooks/useWindowSize.tsx +0 -30
- package/src/common/icon/NsIcon.spec.tsx +0 -51
- package/src/common/icon/NsIcon.stories.tsx +0 -77
- package/src/common/icon/NsIcon.styled.tsx +0 -27
- package/src/common/icon/NsIcon.tsx +0 -44
- package/src/common/icon/NsIconVariants.ts +0 -56
- package/src/common/icon/icons/AlertErrorIcon.tsx +0 -48
- package/src/common/icon/icons/ArrowDown.tsx +0 -23
- package/src/common/icon/icons/ArrowLeft.tsx +0 -38
- package/src/common/icon/icons/ArrowRight.tsx +0 -39
- package/src/common/icon/icons/ArrowUp.tsx +0 -20
- package/src/common/icon/icons/Cart.tsx +0 -23
- package/src/common/icon/icons/CartBadge.tsx +0 -47
- package/src/common/icon/icons/Check.tsx +0 -30
- package/src/common/icon/icons/CheckShield.tsx +0 -24
- package/src/common/icon/icons/CheckVerified.tsx +0 -27
- package/src/common/icon/icons/ChevronRight.tsx +0 -31
- package/src/common/icon/icons/CloseIcon.tsx +0 -27
- package/src/common/icon/icons/ErrorIcon.tsx +0 -30
- package/src/common/icon/icons/HamburgerIcon.tsx +0 -35
- package/src/common/icon/icons/InfoFilled.tsx +0 -21
- package/src/common/icon/icons/InfoOutlined.tsx +0 -42
- package/src/common/icon/icons/RoundedClose.tsx +0 -31
- package/src/common/icon/icons/SearchIcon.tsx +0 -32
- package/src/common/icon/icons/SlashIcon.tsx +0 -22
- package/src/common/icon/icons/SuccessIcon.tsx +0 -40
- package/src/common/icon/icons/TrashIcon.tsx +0 -32
- package/src/common/icon/icons/UserIcon.tsx +0 -37
- package/src/common/icon/icons/UserOutline.tsx +0 -29
- package/src/common/icon/icons/WarningIcon.tsx +0 -48
- package/src/common/icon/icons/error.svg +0 -3
- package/src/common/icon/icons/home.tsx +0 -19
- package/src/common/icon/icons/search.svg +0 -3
- package/src/common/icon/icons/success.svg +0 -10
- package/src/common/icon/icons/trash.svg +0 -3
- package/src/common/icon/index.ts +0 -3
- package/src/common/icon/types.d.ts +0 -53
- package/src/common/image/BynderMedia.spec.tsx +0 -42
- package/src/common/image/BynderMedia.tsx +0 -49
- package/src/common/image/NsImage.spec.tsx +0 -60
- package/src/common/image/NsImage.stories.tsx +0 -46
- package/src/common/image/NsImage.tsx +0 -33
- package/src/common/image/NsNextImage.spec.tsx +0 -10
- package/src/common/image/NsNextImage.stories.tsx +0 -51
- package/src/common/image/NsNextImage.tsx +0 -11
- package/src/common/image/bynder-util.spec.ts +0 -187
- package/src/common/image/bynder-util.ts +0 -98
- package/src/common/image/index.ts +0 -3
- package/src/common/image/types.ts +0 -78
- package/src/common/index.ts +0 -37
- package/src/common/input/InputFieldWrapper.tsx +0 -24
- package/src/common/input/InputWrapper.tsx +0 -82
- package/src/common/input/NsInputField.spec.tsx +0 -25
- package/src/common/input/NsInputField.stories.tsx +0 -61
- package/src/common/input/NsInputField.tsx +0 -125
- package/src/common/input/getAdornmentProps.tsx +0 -50
- package/src/common/input/index.ts +0 -2
- package/src/common/input/types.d.ts +0 -45
- package/src/common/label/NsLabel.spec.tsx +0 -11
- package/src/common/label/NsLabel.stories.tsx +0 -35
- package/src/common/label/NsLabel.tsx +0 -43
- package/src/common/label/index.ts +0 -2
- package/src/common/label/types.d.ts +0 -10
- package/src/common/link/NsLink.spec.tsx +0 -106
- package/src/common/link/NsLink.stories.tsx +0 -55
- package/src/common/link/NsLink.styled.tsx +0 -100
- package/src/common/link/NsLink.tsx +0 -122
- package/src/common/link/index.ts +0 -2
- package/src/common/link/types.d.ts +0 -22
- package/src/common/modal/NsModal.spec.tsx +0 -46
- package/src/common/modal/NsModal.styled.tsx +0 -28
- package/src/common/modal/NsModal.tsx +0 -43
- package/src/common/modal/helper-component/NsModalContentBox.tsx +0 -37
- package/src/common/modal/helper-component/NsModalDefault.tsx +0 -34
- package/src/common/modal/helper-component/NsModalStatus.tsx +0 -17
- package/src/common/modal/helper-component/NsModalStatusIcon.tsx +0 -16
- package/src/common/modal/helper-component/NsModalTitle.tsx +0 -29
- package/src/common/modal/index.ts +0 -2
- package/src/common/modal/model/NsModalVariantMap.tsx +0 -24
- package/src/common/modal/stories/NsModal.stories.tsx +0 -87
- package/src/common/modal/stories/mock.tsx +0 -46
- package/src/common/modal/types.ts +0 -57
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +0 -22
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +0 -25
- package/src/common/nav-product-card/NsNavProductCard.styled.tsx +0 -24
- package/src/common/nav-product-card/NsNavProductCard.tsx +0 -27
- package/src/common/nav-product-card/index.ts +0 -2
- package/src/common/nav-product-card/types.d.ts +0 -9
- package/src/common/nav-tab/NavDrawer.tsx +0 -41
- package/src/common/nav-tab/NavTitles.tsx +0 -64
- package/src/common/nav-tab/NsNavTab.spec.tsx +0 -64
- package/src/common/nav-tab/NsNavTab.stories.tsx +0 -36
- package/src/common/nav-tab/NsNavTab.styled.tsx +0 -74
- package/src/common/nav-tab/NsNavTab.tsx +0 -43
- package/src/common/nav-tab/index.ts +0 -2
- package/src/common/nav-tab/types.d.ts +0 -21
- package/src/common/progress/NsProgress.spec.tsx +0 -47
- package/src/common/progress/NsProgress.stories.tsx +0 -45
- package/src/common/progress/NsProgress.styled.tsx +0 -56
- package/src/common/progress/NsProgress.tsx +0 -29
- package/src/common/progress/index.ts +0 -2
- package/src/common/progress/types.d.ts +0 -21
- package/src/common/radiogroup/NsRadioGroup.spec.tsx +0 -63
- package/src/common/radiogroup/NsRadioGroup.stories.tsx +0 -84
- package/src/common/radiogroup/NsRadioGroup.styled.tsx +0 -51
- package/src/common/radiogroup/NsRadioGroup.tsx +0 -65
- package/src/common/radiogroup/index.ts +0 -2
- package/src/common/radiogroup/types.d.ts +0 -19
- package/src/common/search-bar/NsSeachBar.spec.tsx +0 -9
- package/src/common/search-bar/NsSearchBar.tsx +0 -46
- package/src/common/select/DefaultRenderOption.tsx +0 -8
- package/src/common/select/NsSelect.styled.tsx +0 -102
- package/src/common/select/NsSelect.tsx +0 -166
- package/src/common/select/NsSelectOption.tsx +0 -26
- package/src/common/select/constant.ts +0 -30
- package/src/common/select/index.ts +0 -3
- package/src/common/select/specs/NsSelect.spec.tsx +0 -183
- package/src/common/select/specs/NsSelectOption.spec.tsx +0 -32
- package/src/common/select/stories/NsSelect.stories.tsx +0 -89
- package/src/common/select/stories/countries.ts +0 -53
- package/src/common/select/types.d.ts +0 -49
- package/src/common/spinner/NsSpinner.spec.tsx +0 -21
- package/src/common/spinner/NsSpinner.stories.tsx +0 -29
- package/src/common/spinner/NsSpinner.styled.tsx +0 -344
- package/src/common/spinner/NsSpinner.tsx +0 -15
- package/src/common/spinner/icons/Spinner.tsx +0 -163
- package/src/common/spinner/index.ts +0 -2
- package/src/common/spinner/types.ts +0 -5
- package/src/common/table/NsExpandableRow.tsx +0 -62
- package/src/common/table/NsTable.spec.tsx +0 -174
- package/src/common/table/NsTable.stories.tsx +0 -156
- package/src/common/table/NsTable.styled.ts +0 -127
- package/src/common/table/NsTable.tsx +0 -150
- package/src/common/table/NsTableHeader.tsx +0 -54
- package/src/common/table/NsTablePagination.tsx +0 -24
- package/src/common/table/helper.ts +0 -33
- package/src/common/table/index.ts +0 -2
- package/src/common/table/types.d.ts +0 -57
- package/src/common/text-strip/NsTextStrip.spec.tsx +0 -27
- package/src/common/text-strip/NsTextStrip.stories.tsx +0 -61
- package/src/common/text-strip/NsTextStrip.tsx +0 -61
- package/src/common/text-strip/index.ts +0 -2
- package/src/common/text-strip/types.d.ts +0 -16
- package/src/common/toast/Fade.tsx +0 -98
- package/src/common/toast/ToastProvider.tsx +0 -88
- package/src/common/toast/index.ts +0 -3
- package/src/common/toast/shared.ts +0 -124
- package/src/common/toast/specs/Toast.spec.tsx +0 -122
- package/src/common/toast/stories/Toast.stories.tsx +0 -82
- package/src/common/toast/useToast.tsx +0 -65
- package/src/common/typography/GlobalFontInter.tsx +0 -15
- package/src/common/typography/HtmlTagVariantMap.tsx +0 -24
- package/src/common/typography/NsTypography.spec.tsx +0 -37
- package/src/common/typography/NsTypography.stories.tsx +0 -27
- package/src/common/typography/NsTypography.tsx +0 -44
- package/src/common/typography/Typography.styled.tsx +0 -195
- package/src/common/typography/__snapshots__/NsTypography.spec.tsx.snap +0 -22
- package/src/common/typography/index.ts +0 -3
- package/src/common/typography/types.d.ts +0 -37
- package/src/common/util.ts +0 -3
- package/src/common/utility/Show.tsx +0 -13
- package/src/common/utility/index.ts +0 -1
- package/src/common/validations/regex.ts +0 -2
- package/src/common/videos/NsVideo.spec.tsx +0 -26
- package/src/common/videos/NsVideo.stories.tsx +0 -32
- package/src/common/videos/NsVideo.tsx +0 -28
- package/src/common/videos/index.ts +0 -2
- package/src/common/videos/types.d.ts +0 -9
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent, screen } from '@/test-utils/index';
|
|
3
|
-
import { AccordionContentTypeObject, AccordionItem, AccordionVariant, NsAccordion } from '@/common/index';
|
|
4
|
-
|
|
5
|
-
const generateContentArray = (count: number, isDefaultOpen = true) => {
|
|
6
|
-
const arr = [] as AccordionItem[];
|
|
7
|
-
for (let i = 1; i <= count; i++) {
|
|
8
|
-
arr?.push({
|
|
9
|
-
title: `Title ${i}`,
|
|
10
|
-
content: <div className="p-2">Content {i}</div>,
|
|
11
|
-
isDefaultOpen,
|
|
12
|
-
type: AccordionContentTypeObject.jsx,
|
|
13
|
-
id: `Test ${i}`,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return arr;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
describe('NsAccordion', () => {
|
|
20
|
-
const items = generateContentArray(3);
|
|
21
|
-
const defaultProps = {
|
|
22
|
-
additionalProps: {
|
|
23
|
-
testid: 'test-accordion',
|
|
24
|
-
},
|
|
25
|
-
allowMultipleExpanded: false,
|
|
26
|
-
items,
|
|
27
|
-
variant: AccordionVariant.Basic,
|
|
28
|
-
invert: false,
|
|
29
|
-
level: 0,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
it('1. renders without error', () => {
|
|
33
|
-
const { getByTestId } = render(<NsAccordion {...defaultProps} />);
|
|
34
|
-
const accordion = getByTestId(defaultProps.additionalProps.testid);
|
|
35
|
-
expect(accordion).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it(`2. only first section should be visible when allowMultipleExpanded prop is false and multiple items have
|
|
39
|
-
isDefaultOpen true`, () => {
|
|
40
|
-
const { getAllByText } = render(<NsAccordion {...defaultProps} />);
|
|
41
|
-
const [title1, title2, title3] = getAllByText(/Title /i);
|
|
42
|
-
|
|
43
|
-
expect(title1.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
44
|
-
expect(title2.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
45
|
-
expect(title3.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
46
|
-
const [c1, c2, c3] = getAllByText(/Content /i);
|
|
47
|
-
expect(c1.parentNode).toHaveStyle('opacity: 1');
|
|
48
|
-
expect(c2.parentNode).toHaveStyle('opacity: 0');
|
|
49
|
-
expect(c3.parentNode).toHaveStyle('opacity: 0');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it(`3. expands second section only when allowMultipleExpanded
|
|
53
|
-
prop is false and second title is clicked`, async () => {
|
|
54
|
-
const { getAllByText } = render(<NsAccordion {...defaultProps} />);
|
|
55
|
-
const [title1, title2, title3] = getAllByText(/Title /i);
|
|
56
|
-
const header = title2.closest('header');
|
|
57
|
-
expect(header).toHaveAttribute('aria-expanded', 'false');
|
|
58
|
-
if (header) {
|
|
59
|
-
fireEvent.click(header);
|
|
60
|
-
expect(title1.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
61
|
-
expect(title2.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
62
|
-
expect(title3.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
63
|
-
const [c1, c2, c3] = getAllByText(/Content /i);
|
|
64
|
-
expect(c1.parentNode).toHaveStyle('opacity: 0');
|
|
65
|
-
expect(c2.parentNode).toHaveStyle('opacity: 1');
|
|
66
|
-
expect(c3.parentNode).toHaveStyle('opacity: 0');
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('4. expands multiple sections by default when allowMultipleExpanded prop is true', () => {
|
|
71
|
-
const items = generateContentArray(3);
|
|
72
|
-
items[2].isDefaultOpen = false;
|
|
73
|
-
const defaultProps = {
|
|
74
|
-
allowMultipleExpanded: false,
|
|
75
|
-
items,
|
|
76
|
-
variant: AccordionVariant.Basic,
|
|
77
|
-
level: 0,
|
|
78
|
-
invert: false,
|
|
79
|
-
};
|
|
80
|
-
const { getAllByText } = render(<NsAccordion {...defaultProps} allowMultipleExpanded />);
|
|
81
|
-
const accordion = screen.getByTestId('ns-accordion-testid');
|
|
82
|
-
expect(accordion).toBeDefined();
|
|
83
|
-
const [title1, title2, title3] = getAllByText(/Title /i);
|
|
84
|
-
|
|
85
|
-
expect(title1.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
86
|
-
expect(title2.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
87
|
-
expect(title3.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
88
|
-
|
|
89
|
-
const [c1, c2, c3] = getAllByText(/Content /i);
|
|
90
|
-
expect(c1.parentNode).toHaveStyle('opacity: 1');
|
|
91
|
-
expect(c2.parentNode).toHaveStyle('opacity: 1');
|
|
92
|
-
expect(c3.parentNode).toHaveStyle('opacity: 0');
|
|
93
|
-
|
|
94
|
-
fireEvent.click(title3);
|
|
95
|
-
|
|
96
|
-
expect(title1.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
97
|
-
expect(title2.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
98
|
-
expect(title3.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
99
|
-
|
|
100
|
-
const [c11, c12, c13] = getAllByText(/Content /i);
|
|
101
|
-
expect(c11.parentNode).toHaveStyle('opacity: 1');
|
|
102
|
-
expect(c12.parentNode).toHaveStyle('opacity: 1');
|
|
103
|
-
expect(c13.parentNode).toHaveStyle('opacity: 1');
|
|
104
|
-
});
|
|
105
|
-
it(`5. closes second section also when allowMultipleExpanded
|
|
106
|
-
prop is true and second title is clicked`, async () => {
|
|
107
|
-
const items = generateContentArray(3);
|
|
108
|
-
const defaultProps = {
|
|
109
|
-
additionalProps: {
|
|
110
|
-
testid: 'test-accordion',
|
|
111
|
-
},
|
|
112
|
-
allowMultipleExpanded: true,
|
|
113
|
-
items,
|
|
114
|
-
variant: AccordionVariant.Basic,
|
|
115
|
-
invert: false,
|
|
116
|
-
level: 0,
|
|
117
|
-
};
|
|
118
|
-
const { getAllByText } = render(<NsAccordion {...defaultProps} />);
|
|
119
|
-
const [title1, title2, title3] = getAllByText(/Title /i);
|
|
120
|
-
const header = title2.closest('header');
|
|
121
|
-
expect(header).toHaveAttribute('aria-expanded', 'true');
|
|
122
|
-
if (header) {
|
|
123
|
-
fireEvent.click(header);
|
|
124
|
-
expect(title1.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
125
|
-
expect(title2.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
126
|
-
expect(title3.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
127
|
-
|
|
128
|
-
const [c1, c2, c3] = getAllByText(/Content /i);
|
|
129
|
-
expect(c1.parentNode).toHaveStyle('opacity: 1');
|
|
130
|
-
expect(c2.parentNode).toHaveStyle('opacity: 0');
|
|
131
|
-
expect(c3.parentNode).toHaveStyle('opacity: 1');
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
it(`6. closes second section also when allowMultipleExpanded
|
|
135
|
-
prop is true and second title is clicked`, async () => {
|
|
136
|
-
const items = generateContentArray(3, false);
|
|
137
|
-
items[1].isDefaultOpen = true;
|
|
138
|
-
const defaultProps = {
|
|
139
|
-
additionalProps: {
|
|
140
|
-
testid: 'test-accordion',
|
|
141
|
-
},
|
|
142
|
-
allowMultipleExpanded: false,
|
|
143
|
-
items,
|
|
144
|
-
variant: AccordionVariant.Compact,
|
|
145
|
-
level: 0,
|
|
146
|
-
invert: false,
|
|
147
|
-
};
|
|
148
|
-
const { getAllByText } = render(<NsAccordion {...defaultProps} />);
|
|
149
|
-
const [title1, title2, title3] = getAllByText(/Title /i);
|
|
150
|
-
const header = title2.closest('header');
|
|
151
|
-
expect(header).toHaveAttribute('aria-expanded', 'true');
|
|
152
|
-
if (header) {
|
|
153
|
-
fireEvent.click(header);
|
|
154
|
-
expect(title1.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
155
|
-
expect(title2.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
156
|
-
expect(title3.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
157
|
-
const [c1, c2, c3] = getAllByText(/Content /i);
|
|
158
|
-
expect(c1.parentNode).toHaveStyle('opacity: 0');
|
|
159
|
-
expect(c2.parentNode).toHaveStyle('opacity: 0');
|
|
160
|
-
expect(c3.parentNode).toHaveStyle('opacity: 0');
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
it('7. shows end icon only when showEndIconWhenEmpty is true', async () => {
|
|
164
|
-
const items = generateContentArray(3, false);
|
|
165
|
-
const defaultProps = {
|
|
166
|
-
additionalProps: {
|
|
167
|
-
testid: 'test-accordion',
|
|
168
|
-
},
|
|
169
|
-
allowMultipleExpanded: false,
|
|
170
|
-
items,
|
|
171
|
-
variant: AccordionVariant.Compact,
|
|
172
|
-
level: 0,
|
|
173
|
-
invert: false,
|
|
174
|
-
showEndIconWhenEmpty: true,
|
|
175
|
-
};
|
|
176
|
-
const { getAllByTestId } = render(<NsAccordion {...defaultProps} />);
|
|
177
|
-
const elements = getAllByTestId('arrowDown');
|
|
178
|
-
|
|
179
|
-
elements.forEach((element) => {
|
|
180
|
-
expect(element).toBeInTheDocument();
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@/test-utils/index';
|
|
3
|
-
import { NsAccordionHeader, AccordionVariant, NsLink } from '@/common/index';
|
|
4
|
-
|
|
5
|
-
const content = [
|
|
6
|
-
{
|
|
7
|
-
type: 'text',
|
|
8
|
-
id: '1',
|
|
9
|
-
title: 'title1',
|
|
10
|
-
content: (
|
|
11
|
-
<div>
|
|
12
|
-
<p>1</p>
|
|
13
|
-
<p>2</p>
|
|
14
|
-
</div>
|
|
15
|
-
),
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: 'text',
|
|
19
|
-
id: '2',
|
|
20
|
-
title: <NsLink href={'/test'}>title2</NsLink>,
|
|
21
|
-
content: null,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: 'text',
|
|
25
|
-
id: '3',
|
|
26
|
-
title: 'title3',
|
|
27
|
-
content: (
|
|
28
|
-
<div>
|
|
29
|
-
<p>1</p>
|
|
30
|
-
<p>2</p>
|
|
31
|
-
<p>3</p>
|
|
32
|
-
</div>
|
|
33
|
-
),
|
|
34
|
-
},
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
describe('NsAccordionHeader', () => {
|
|
38
|
-
it('1. renders title correctly', () => {
|
|
39
|
-
const onClick = jest.fn();
|
|
40
|
-
const title = 'Section Header';
|
|
41
|
-
|
|
42
|
-
const { getByText } = render(
|
|
43
|
-
<NsAccordionHeader
|
|
44
|
-
variant={AccordionVariant.Basic}
|
|
45
|
-
title={title}
|
|
46
|
-
onClick={onClick}
|
|
47
|
-
invert={false}
|
|
48
|
-
isOpen={true}
|
|
49
|
-
content={content}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
const el = getByText(title);
|
|
53
|
-
expect(el).toBeInTheDocument();
|
|
54
|
-
expect(el.closest('header')).toHaveAttribute('aria-expanded', 'true');
|
|
55
|
-
});
|
|
56
|
-
it('2. renders title correctly', () => {
|
|
57
|
-
const onClick = jest.fn();
|
|
58
|
-
const title = 'Section Header';
|
|
59
|
-
const { getByText } = render(
|
|
60
|
-
<NsAccordionHeader
|
|
61
|
-
variant={AccordionVariant.Compact}
|
|
62
|
-
title={<span>{title}</span>}
|
|
63
|
-
onClick={onClick}
|
|
64
|
-
invert={false}
|
|
65
|
-
isOpen={false}
|
|
66
|
-
content={content}
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
const el = getByText(title);
|
|
70
|
-
expect(el).toBeInTheDocument();
|
|
71
|
-
expect(el.closest('header')).toHaveAttribute('aria-expanded', 'false');
|
|
72
|
-
});
|
|
73
|
-
it('3. calls onClick handler when clicked', () => {
|
|
74
|
-
const onClick = jest.fn();
|
|
75
|
-
const { container } = render(
|
|
76
|
-
<NsAccordionHeader
|
|
77
|
-
variant={AccordionVariant.Basic}
|
|
78
|
-
title="Section Header"
|
|
79
|
-
onClick={onClick}
|
|
80
|
-
invert={false}
|
|
81
|
-
isOpen={false}
|
|
82
|
-
content={content}
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
85
|
-
const header = container.querySelector('header');
|
|
86
|
-
if (header) {
|
|
87
|
-
fireEvent.click(header);
|
|
88
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('4. renders with additional class name', () => {
|
|
93
|
-
const additionalClassName = 'custom-class';
|
|
94
|
-
const onClick = jest.fn();
|
|
95
|
-
const { container } = render(
|
|
96
|
-
<NsAccordionHeader
|
|
97
|
-
isOpen={false}
|
|
98
|
-
variant={AccordionVariant.Basic}
|
|
99
|
-
title="Section Header"
|
|
100
|
-
additionalProps={{ className: additionalClassName }}
|
|
101
|
-
onClick={onClick}
|
|
102
|
-
invert={false}
|
|
103
|
-
content={content}
|
|
104
|
-
/>
|
|
105
|
-
);
|
|
106
|
-
expect(container.querySelector('header')).toHaveClass(`section-header ${additionalClassName}`);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('5. renders with expanded class when isOpen is true', () => {
|
|
110
|
-
const onClick = jest.fn();
|
|
111
|
-
const { container } = render(
|
|
112
|
-
<NsAccordionHeader
|
|
113
|
-
variant={AccordionVariant.Basic}
|
|
114
|
-
title="Section Header"
|
|
115
|
-
isOpen
|
|
116
|
-
onClick={onClick}
|
|
117
|
-
invert={false}
|
|
118
|
-
content={content}
|
|
119
|
-
/>
|
|
120
|
-
);
|
|
121
|
-
expect(container.querySelector('header')).toHaveClass('expanded');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('6. renders with header icon when showEndIconWhenEmpty is true', () => {
|
|
125
|
-
const onClick = jest.fn();
|
|
126
|
-
const { getByTestId } = render(
|
|
127
|
-
<NsAccordionHeader
|
|
128
|
-
variant={AccordionVariant.Basic}
|
|
129
|
-
title="Section Header"
|
|
130
|
-
onClick={onClick}
|
|
131
|
-
invert={false}
|
|
132
|
-
isOpen
|
|
133
|
-
showEndIconWhenEmpty={true}
|
|
134
|
-
content={content}
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
// this icon refers to end icon which is either arrowUp or arrowDown
|
|
138
|
-
expect(getByTestId('icon')).toBeInTheDocument();
|
|
139
|
-
});
|
|
140
|
-
it('7. renders with custom start icon', () => {
|
|
141
|
-
const onClick = jest.fn();
|
|
142
|
-
const { getByTestId } = render(
|
|
143
|
-
<NsAccordionHeader
|
|
144
|
-
variant={AccordionVariant.Basic}
|
|
145
|
-
title="Section Header"
|
|
146
|
-
onClick={onClick}
|
|
147
|
-
invert={false}
|
|
148
|
-
isOpen
|
|
149
|
-
startIcon={{ name: 'hamburgerIcon', testId: 'hamburger-test' }}
|
|
150
|
-
content={content}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
expect(getByTestId('hamburger-test')).toBeInTheDocument();
|
|
154
|
-
});
|
|
155
|
-
it('8. does not render start icon, when invalid icon name is passed', () => {
|
|
156
|
-
const onClick = jest.fn();
|
|
157
|
-
const invalidIconName = 'hambur';
|
|
158
|
-
const testId = 'hamburger-test';
|
|
159
|
-
const { queryByTestId } = render(
|
|
160
|
-
<NsAccordionHeader
|
|
161
|
-
variant={AccordionVariant.Basic}
|
|
162
|
-
title="Section Header"
|
|
163
|
-
onClick={onClick}
|
|
164
|
-
invert={false}
|
|
165
|
-
isOpen
|
|
166
|
-
startIcon={{ name: invalidIconName as any, testId }}
|
|
167
|
-
content={content}
|
|
168
|
-
/>
|
|
169
|
-
);
|
|
170
|
-
expect(queryByTestId(testId)).toBeNull();
|
|
171
|
-
});
|
|
172
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent } from '@/test-utils/index';
|
|
3
|
-
import { NsAccordionItem, AccordionVariant } from '@/common/index';
|
|
4
|
-
|
|
5
|
-
describe('NsAccordionItem', () => {
|
|
6
|
-
const title = 'Accordion Section Title';
|
|
7
|
-
const content = 'Accordion Section Content';
|
|
8
|
-
const contentElement = <div className="p-2">{content}</div>;
|
|
9
|
-
it('1. renders title correctly', () => {
|
|
10
|
-
const { getByText } = render(
|
|
11
|
-
<NsAccordionItem
|
|
12
|
-
type="jsx"
|
|
13
|
-
variant={AccordionVariant.Basic}
|
|
14
|
-
isOpen={false}
|
|
15
|
-
toggleOpen={() => {}}
|
|
16
|
-
title={title}
|
|
17
|
-
content={contentElement}
|
|
18
|
-
isChild={false}
|
|
19
|
-
invert={false}
|
|
20
|
-
level={1}
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
expect(getByText(title)).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('2. calls toggleOpen function when clicked on the section header', () => {
|
|
27
|
-
const toggleOpen = jest.fn();
|
|
28
|
-
const { getByText } = render(
|
|
29
|
-
<NsAccordionItem
|
|
30
|
-
type="jsx"
|
|
31
|
-
variant={AccordionVariant.Basic}
|
|
32
|
-
isOpen={false}
|
|
33
|
-
toggleOpen={toggleOpen}
|
|
34
|
-
title={title}
|
|
35
|
-
content={contentElement}
|
|
36
|
-
isChild={false}
|
|
37
|
-
invert={false}
|
|
38
|
-
level={1}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
fireEvent.click(getByText(title));
|
|
42
|
-
expect(toggleOpen).toHaveBeenCalledTimes(1);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('3. renders content when isOpen is true', () => {
|
|
46
|
-
const { getByText } = render(
|
|
47
|
-
<NsAccordionItem
|
|
48
|
-
variant={AccordionVariant.Basic}
|
|
49
|
-
isOpen={true}
|
|
50
|
-
toggleOpen={() => {}}
|
|
51
|
-
title={title}
|
|
52
|
-
type="jsx"
|
|
53
|
-
content={contentElement}
|
|
54
|
-
isChild={false}
|
|
55
|
-
invert={false}
|
|
56
|
-
level={1}
|
|
57
|
-
/>
|
|
58
|
-
);
|
|
59
|
-
expect(getByText(content)).toBeInTheDocument();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('4. when isOpen is false, renders jsx dom content within container with 0 height', () => {
|
|
63
|
-
const { queryByText } = render(
|
|
64
|
-
<NsAccordionItem
|
|
65
|
-
type="jsx"
|
|
66
|
-
variant={AccordionVariant.Basic}
|
|
67
|
-
isOpen={false}
|
|
68
|
-
toggleOpen={() => {}}
|
|
69
|
-
title={title}
|
|
70
|
-
content={contentElement}
|
|
71
|
-
isChild={false}
|
|
72
|
-
invert={false}
|
|
73
|
-
level={1}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
const bodyElement = queryByText(content);
|
|
77
|
-
expect(bodyElement?.parentNode).toHaveStyle('height:0px;');
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { AccordionItem, AccordionVariant, NsCollapse } from '@/common/index';
|
|
2
|
-
import { render, screen } from '@/test-utils/index';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
import { createAccordionItem3_1 } from '../stories/data';
|
|
6
|
-
|
|
7
|
-
describe('NsCollapse', () => {
|
|
8
|
-
it('1. renders children when isOpen is true', () => {
|
|
9
|
-
const { getByText } = render(
|
|
10
|
-
<NsCollapse
|
|
11
|
-
isOpen
|
|
12
|
-
variant={AccordionVariant.Basic}
|
|
13
|
-
content={
|
|
14
|
-
<>
|
|
15
|
-
<div>Child 1</div>
|
|
16
|
-
<div>Child 2</div>
|
|
17
|
-
</>
|
|
18
|
-
}
|
|
19
|
-
type="jsx"
|
|
20
|
-
isChild={false}
|
|
21
|
-
invert={false}
|
|
22
|
-
level={0}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
expect(getByText('Child 1')).toBeInTheDocument();
|
|
26
|
-
expect(getByText('Child 2')).toBeInTheDocument();
|
|
27
|
-
});
|
|
28
|
-
it('2. renders children when isOpen is true and isChild is true', () => {
|
|
29
|
-
const content = 'renders children when isOpen is true and isChild is true';
|
|
30
|
-
const { getByText } = render(
|
|
31
|
-
<NsCollapse
|
|
32
|
-
isOpen
|
|
33
|
-
type="text"
|
|
34
|
-
variant={AccordionVariant.Basic}
|
|
35
|
-
content={content}
|
|
36
|
-
isChild={true}
|
|
37
|
-
invert={false}
|
|
38
|
-
level={0}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
expect(getByText(content)).toBeInTheDocument();
|
|
42
|
-
});
|
|
43
|
-
it('3. renders children when isOpen is true and variant is compact and content is of type accordion', () => {
|
|
44
|
-
const accItem = createAccordionItem3_1();
|
|
45
|
-
const content = accItem.content as AccordionItem[];
|
|
46
|
-
const { getByText } = render(
|
|
47
|
-
<NsCollapse
|
|
48
|
-
isOpen
|
|
49
|
-
variant={AccordionVariant.Compact}
|
|
50
|
-
content={content}
|
|
51
|
-
type={accItem.type}
|
|
52
|
-
isChild={true}
|
|
53
|
-
invert={false}
|
|
54
|
-
level={0}
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
expect(getByText(content[0].title as string)).toBeInTheDocument();
|
|
58
|
-
expect(getByText(content[1].title as string)).toBeInTheDocument();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('4. does not render children when isOpen is false', () => {
|
|
62
|
-
const content = '<h2>Lorem ipsum dolor sit amet.</h2>';
|
|
63
|
-
render(
|
|
64
|
-
<NsCollapse
|
|
65
|
-
isOpen={false}
|
|
66
|
-
variant={AccordionVariant.Basic}
|
|
67
|
-
type="html"
|
|
68
|
-
content={content}
|
|
69
|
-
isChild={false}
|
|
70
|
-
invert={true}
|
|
71
|
-
level={0}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
expect(screen.queryByText(content)).toBeNull();
|
|
75
|
-
});
|
|
76
|
-
it('5. renders html children when isOpen is true', () => {
|
|
77
|
-
const content = '<h2>Lorem ipsum dolor sit amet.</h2>';
|
|
78
|
-
render(
|
|
79
|
-
<NsCollapse
|
|
80
|
-
isOpen={true}
|
|
81
|
-
variant={AccordionVariant.Compact}
|
|
82
|
-
type="html"
|
|
83
|
-
content={content}
|
|
84
|
-
isChild={false}
|
|
85
|
-
invert={true}
|
|
86
|
-
level={0}
|
|
87
|
-
/>
|
|
88
|
-
);
|
|
89
|
-
expect(screen.queryByText(content)).toBeDefined();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('6. renders with additional class name', () => {
|
|
93
|
-
const additionalClassName = 'custom-class';
|
|
94
|
-
const { container } = render(
|
|
95
|
-
<NsCollapse
|
|
96
|
-
type="jsx"
|
|
97
|
-
isOpen
|
|
98
|
-
variant={AccordionVariant.Gray}
|
|
99
|
-
content={
|
|
100
|
-
<>
|
|
101
|
-
<div>Child 1</div>
|
|
102
|
-
<div>Child 2</div>
|
|
103
|
-
</>
|
|
104
|
-
}
|
|
105
|
-
additionalProps={{ className: additionalClassName }}
|
|
106
|
-
isChild={false}
|
|
107
|
-
invert={false}
|
|
108
|
-
level={7}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
expect(container.querySelector('section')).toHaveClass(`ns-collapse ${additionalClassName}`);
|
|
112
|
-
});
|
|
113
|
-
it('7. skipping allowMultipleExpanded in child data', () => {
|
|
114
|
-
const { content, type } = createAccordionItem3_1();
|
|
115
|
-
const additionalClassName = 'custom-class';
|
|
116
|
-
const { container } = render(
|
|
117
|
-
<NsCollapse
|
|
118
|
-
type={type}
|
|
119
|
-
isOpen
|
|
120
|
-
variant={AccordionVariant.Gray}
|
|
121
|
-
content={content}
|
|
122
|
-
additionalProps={{ className: additionalClassName }}
|
|
123
|
-
isChild={false}
|
|
124
|
-
invert={true}
|
|
125
|
-
level={7}
|
|
126
|
-
/>
|
|
127
|
-
);
|
|
128
|
-
expect(container.querySelector('section')).toHaveClass(`ns-collapse ${additionalClassName}`);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { AccordionVariant, NsToggleSection } from '@/common/index';
|
|
4
|
-
|
|
5
|
-
import { render, fireEvent } from '@/test-utils/index';
|
|
6
|
-
|
|
7
|
-
describe('NsToggleSection', () => {
|
|
8
|
-
const title = 'Toggle Section Title';
|
|
9
|
-
const contentText = 'Toggle Section Content';
|
|
10
|
-
const content = <div className="p-2">{contentText}</div>;
|
|
11
|
-
it('1. renders title correctly', () => {
|
|
12
|
-
const { getByText } = render(
|
|
13
|
-
<NsToggleSection
|
|
14
|
-
variant={AccordionVariant.Basic}
|
|
15
|
-
title={title}
|
|
16
|
-
content={content}
|
|
17
|
-
invert={false}
|
|
18
|
-
isChild={false}
|
|
19
|
-
type="jsx"
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
expect(getByText(title)).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
it('2. renders title correctly', () => {
|
|
25
|
-
const { getByText } = render(
|
|
26
|
-
<NsToggleSection
|
|
27
|
-
variant={AccordionVariant.Compact}
|
|
28
|
-
title={title}
|
|
29
|
-
content={content}
|
|
30
|
-
invert={false}
|
|
31
|
-
isChild={false}
|
|
32
|
-
type="jsx"
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
expect(getByText(title)).toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('2. toggles content visibility when clicked on the section header', () => {
|
|
39
|
-
const { getByText, queryByText } = render(
|
|
40
|
-
<NsToggleSection
|
|
41
|
-
variant={AccordionVariant.Basic}
|
|
42
|
-
title={title}
|
|
43
|
-
content={content}
|
|
44
|
-
invert={false}
|
|
45
|
-
isChild={false}
|
|
46
|
-
type="jsx"
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
const el = queryByText(contentText);
|
|
50
|
-
expect(el?.parentNode).toHaveStyle('opacity: 0;');
|
|
51
|
-
|
|
52
|
-
fireEvent.click(getByText(title));
|
|
53
|
-
expect(el?.parentNode).toHaveStyle('opacity: 1;');
|
|
54
|
-
|
|
55
|
-
fireEvent.click(getByText(title));
|
|
56
|
-
expect(el?.parentNode).toHaveStyle('opacity: 0;');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('3. sets defaultOpen prop correctly', () => {
|
|
60
|
-
const { getByText } = render(
|
|
61
|
-
<NsToggleSection
|
|
62
|
-
variant={AccordionVariant.Basic}
|
|
63
|
-
title={title}
|
|
64
|
-
content={content}
|
|
65
|
-
invert={false}
|
|
66
|
-
isChild={false}
|
|
67
|
-
defaultOpen
|
|
68
|
-
type="jsx"
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
expect(getByText(contentText)).toBeInTheDocument();
|
|
73
|
-
});
|
|
74
|
-
});
|