@faststore/ui 2.0.2-alpha.0 → 2.0.4-alpha.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/CHANGELOG.md +18 -0
- package/dist/assets/ShoppingCart.d.ts +2 -2
- package/dist/assets/ShoppingCart.js.map +1 -1
- package/dist/assets/X.d.ts +2 -2
- package/dist/assets/X.js.map +1 -1
- package/package.json +30 -37
- package/src/assets/ShoppingCart.tsx +50 -0
- package/src/assets/X.tsx +38 -0
- package/src/base/layout.scss +78 -0
- package/src/base/tokens.scss +274 -0
- package/src/base/typography.scss +64 -0
- package/src/components/atoms/Badge/Badge.stories.mdx +156 -0
- package/src/components/atoms/Badge/styles.scss +209 -0
- package/src/components/atoms/Button/Button.stories.mdx +110 -0
- package/src/components/atoms/Button/styles.scss +316 -0
- package/src/components/atoms/Checkbox/styles.scss +155 -0
- package/src/{atoms → components/atoms}/Incentive/Incentive.tsx +0 -0
- package/src/{atoms → components/atoms}/Incentive/index.tsx +0 -0
- package/src/{atoms → components/atoms}/Incentive/stories/Incentive.mdx +0 -0
- package/src/{atoms → components/atoms}/Incentive/stories/Incentive.stories.tsx +0 -0
- package/src/{atoms → components/atoms}/Incentive/stories/assets/Icons.tsx +0 -0
- package/src/{atoms → components/atoms}/Input/Input.tsx +0 -0
- package/src/{atoms → components/atoms}/Input/index.ts +0 -0
- package/src/{atoms → components/atoms}/Input/stories/Input.mdx +0 -0
- package/src/{atoms → components/atoms}/Input/stories/Input.stories.tsx +1 -1
- package/src/components/atoms/Label/Label.stories.mdx +65 -0
- package/src/{atoms → components/atoms}/Link/Link.tsx +1 -1
- package/src/{atoms → components/atoms}/Link/index.tsx +0 -0
- package/src/{atoms → components/atoms}/Link/stories/Link.mdx +0 -0
- package/src/{atoms → components/atoms}/Link/stories/Link.stories.tsx +0 -0
- package/src/{atoms → components/atoms}/List/List.tsx +0 -0
- package/src/{atoms → components/atoms}/List/index.ts +0 -0
- package/src/{atoms → components/atoms}/List/stories/List.mdx +0 -0
- package/src/{atoms → components/atoms}/List/stories/List.stories.tsx +1 -1
- package/src/{atoms → components/atoms}/Overlay/Overlay.tsx +0 -0
- package/src/{atoms → components/atoms}/Overlay/index.ts +0 -0
- package/src/{atoms → components/atoms}/Overlay/stories/Overlay.mdx +0 -0
- package/src/{atoms → components/atoms}/Overlay/stories/Overlay.stories.tsx +1 -1
- package/src/{atoms → components/atoms}/Popover/Popover.tsx +0 -0
- package/src/{atoms → components/atoms}/Popover/index.ts +0 -0
- package/src/{atoms → components/atoms}/Popover/stories/Popover.mdx +0 -0
- package/src/{atoms → components/atoms}/Popover/stories/Popover.stories.tsx +1 -1
- package/src/{atoms → components/atoms}/Price/Price.tsx +0 -0
- package/src/{atoms → components/atoms}/Price/index.ts +0 -0
- package/src/{atoms → components/atoms}/Price/stories/Price.mdx +0 -0
- package/src/{atoms → components/atoms}/Price/stories/Price.stories.tsx +1 -1
- package/src/components/atoms/Radio/Radio.stories.mdx +101 -0
- package/src/components/atoms/Radio/styles.scss +108 -0
- package/src/{atoms → components/atoms}/Select/Select.tsx +0 -0
- package/src/{atoms → components/atoms}/Select/index.ts +0 -0
- package/src/{atoms → components/atoms}/Select/stories/Select.mdx +0 -0
- package/src/{atoms → components/atoms}/Select/stories/Select.stories.tsx +1 -1
- package/src/{atoms → components/atoms}/Skeleton/Skeleton.tsx +0 -0
- package/src/{atoms → components/atoms}/Skeleton/index.ts +0 -0
- package/src/{atoms → components/atoms}/Skeleton/stories/Skeleton.mdx +0 -0
- package/src/{atoms → components/atoms}/Skeleton/stories/Skeleton.stories.tsx +0 -0
- package/src/{atoms → components/atoms}/Slider/Slider.tsx +0 -0
- package/src/{atoms → components/atoms}/Slider/index.ts +0 -0
- package/src/{atoms → components/atoms}/Slider/stories/Slider.mdx +0 -0
- package/src/{atoms → components/atoms}/Slider/stories/Slider.stories.tsx +1 -1
- package/src/{atoms → components/atoms}/Spinner/Spinner.tsx +0 -0
- package/src/{atoms → components/atoms}/Spinner/index.tsx +0 -0
- package/src/{atoms → components/atoms}/Spinner/stories/Spinner.mdx +0 -0
- package/src/{atoms → components/atoms}/Spinner/stories/Spinner.stories.tsx +0 -0
- package/src/{atoms → components/atoms}/TextArea/TextArea.tsx +0 -0
- package/src/{atoms → components/atoms}/TextArea/index.ts +0 -0
- package/src/{atoms → components/atoms}/TextArea/stories/TextArea.mdx +0 -0
- package/src/{atoms → components/atoms}/TextArea/stories/TextArea.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Accordion/Accordion.tsx +0 -0
- package/src/{molecules → components/molecules}/Accordion/AccordionButton.tsx +4 -4
- package/src/{molecules → components/molecules}/Accordion/AccordionItem.tsx +1 -1
- package/src/{molecules → components/molecules}/Accordion/AccordionPanel.tsx +0 -0
- package/src/{molecules → components/molecules}/Accordion/index.ts +0 -0
- package/src/{molecules → components/molecules}/Accordion/stories/Accordion.mdx +0 -0
- package/src/{molecules → components/molecules}/Accordion/stories/Accordion.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/AggregateRating/AggregateRating.tsx +0 -0
- package/src/{molecules → components/molecules}/AggregateRating/index.ts +0 -0
- package/src/{molecules → components/molecules}/AggregateRating/stories/AggregateRating.mdx +0 -0
- package/src/{molecules → components/molecules}/AggregateRating/stories/AggregateRating.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Alert/Alert.tsx +0 -0
- package/src/{molecules → components/molecules}/Alert/index.ts +0 -0
- package/src/{molecules → components/molecules}/Alert/stories/Alert.mdx +0 -0
- package/src/{molecules → components/molecules}/Alert/stories/Alert.stories.tsx +3 -3
- package/src/{molecules → components/molecules}/Banner/Banner.tsx +0 -0
- package/src/{molecules → components/molecules}/Banner/BannerContent.tsx +0 -0
- package/src/{molecules → components/molecules}/Banner/BannerImage.tsx +0 -0
- package/src/{molecules → components/molecules}/Banner/BannerLink.tsx +0 -0
- package/src/{molecules → components/molecules}/Banner/index.ts +0 -0
- package/src/{molecules → components/molecules}/Banner/stories/Banner.mdx +0 -0
- package/src/{molecules → components/molecules}/Banner/stories/Banner.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Breadcrumb/Breadcrumb.tsx +0 -0
- package/src/{molecules → components/molecules}/Breadcrumb/index.ts +0 -0
- package/src/{molecules → components/molecules}/Breadcrumb/stories/Breadcrumb.mdx +0 -0
- package/src/{molecules → components/molecules}/Breadcrumb/stories/Breadcrumb.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Bullets/Bullets.tsx +1 -1
- package/src/{molecules → components/molecules}/Bullets/index.ts +0 -0
- package/src/{molecules → components/molecules}/Bullets/stories/Bullets.mdx +0 -0
- package/src/{molecules → components/molecules}/Bullets/stories/Bullets.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Card/Card.tsx +0 -0
- package/src/{molecules → components/molecules}/Card/CardActions.tsx +0 -0
- package/src/{molecules → components/molecules}/Card/CardContent.tsx +0 -0
- package/src/{molecules → components/molecules}/Card/CardImage.tsx +0 -0
- package/src/{molecules → components/molecules}/Card/index.tsx +0 -0
- package/src/{molecules → components/molecules}/Card/stories/Card.mdx +0 -0
- package/src/{molecules → components/molecules}/Card/stories/Card.stories.tsx +5 -5
- package/src/{molecules → components/molecules}/Carousel/Arrows.tsx +0 -0
- package/src/{molecules → components/molecules}/Carousel/Carousel.tsx +2 -2
- package/src/{molecules → components/molecules}/Carousel/CarouselItem.tsx +1 -1
- package/src/{molecules → components/molecules}/Carousel/hooks/useSlideVisibility.ts +0 -0
- package/src/{molecules → components/molecules}/Carousel/index.ts +0 -0
- package/src/{molecules → components/molecules}/Carousel/stories/Carousel.mdx +0 -0
- package/src/{molecules → components/molecules}/Carousel/stories/Carousel.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/CartItem/CartItem.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/CartItemActions.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/CartItemContent.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/CartItemImage.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/CartItemPrices.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/CartItemSummary.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/CartItemTitle.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/index.tsx +0 -0
- package/src/{molecules → components/molecules}/CartItem/stories/CartItem.mdx +0 -0
- package/src/{molecules → components/molecules}/CartItem/stories/CartItem.stories.tsx +1 -1
- package/src/components/molecules/CheckboxField/CheckboxField.stories.mdx +38 -0
- package/src/components/molecules/CheckboxField/styles.scss +12 -0
- package/src/{molecules → components/molecules}/Dropdown/Dropdown.tsx +0 -0
- package/src/{molecules → components/molecules}/Dropdown/DropdownButton.tsx +0 -0
- package/src/{molecules → components/molecules}/Dropdown/DropdownItem.tsx +0 -0
- package/src/{molecules → components/molecules}/Dropdown/DropdownMenu.tsx +0 -0
- package/src/{molecules → components/molecules}/Dropdown/contexts/DropdownContext.ts +0 -0
- package/src/{molecules → components/molecules}/Dropdown/hooks/useDropdown.ts +0 -0
- package/src/{molecules → components/molecules}/Dropdown/hooks/useDropdownPosition.ts +0 -0
- package/src/{molecules → components/molecules}/Dropdown/index.ts +0 -0
- package/src/{molecules → components/molecules}/Dropdown/stories/Dropdown.mdx +0 -0
- package/src/{molecules → components/molecules}/Dropdown/stories/Dropdown.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Dropdown/stories/assets/Caret.tsx +0 -0
- package/src/{molecules → components/molecules}/Form/Form.tsx +0 -0
- package/src/{molecules → components/molecules}/Form/index.ts +0 -0
- package/src/{molecules → components/molecules}/Form/stories/Form.mdx +0 -0
- package/src/{molecules → components/molecules}/Form/stories/Form.stories.tsx +2 -1
- package/src/{molecules → components/molecules}/Gift/Gift.tsx +2 -3
- package/src/{molecules → components/molecules}/Gift/GiftContent.tsx +0 -0
- package/src/{molecules → components/molecules}/Gift/GiftImage.tsx +0 -0
- package/src/{molecules → components/molecules}/Gift/index.tsx +0 -0
- package/src/{molecules → components/molecules}/Gift/stories/Gift.mdx +0 -0
- package/src/{molecules → components/molecules}/Gift/stories/Gift.stories.tsx +1 -1
- package/src/components/molecules/IconButton/IconButton.stories.mdx +47 -0
- package/src/{molecules → components/molecules}/LoadingButton/LoadingButton.tsx +3 -8
- package/src/{molecules → components/molecules}/LoadingButton/index.tsx +0 -0
- package/src/{molecules → components/molecules}/LoadingButton/stories/LoadingButton.mdx +0 -0
- package/src/{molecules → components/molecules}/LoadingButton/stories/LoadingButton.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Modal/Modal.tsx +0 -0
- package/src/{molecules → components/molecules}/Modal/ModalContent.tsx +0 -0
- package/src/{molecules → components/molecules}/Modal/index.tsx +0 -0
- package/src/{molecules → components/molecules}/Modal/stories/Modal.mdx +0 -0
- package/src/{molecules → components/molecules}/Modal/stories/Modal.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Modal/useTrapFocus.ts +0 -0
- package/src/{molecules → components/molecules}/OrderSummary/OrderSummary.tsx +0 -0
- package/src/{molecules → components/molecules}/OrderSummary/index.tsx +0 -0
- package/src/{molecules → components/molecules}/OrderSummary/stories/OrderSummary.mdx +0 -0
- package/src/{molecules → components/molecules}/OrderSummary/stories/OrderSummary.stories.tsx +0 -0
- package/src/{molecules → components/molecules}/PaymentMethods/PaymentMethods.tsx +0 -0
- package/src/{molecules → components/molecules}/PaymentMethods/index.tsx +0 -0
- package/src/{molecules → components/molecules}/PaymentMethods/stories/PaymentMethods.mdx +0 -0
- package/src/{molecules → components/molecules}/PaymentMethods/stories/PaymentMethods.stories.tsx +0 -0
- package/src/{molecules → components/molecules}/PaymentMethods/stories/assets/Icons.tsx +0 -0
- package/src/{molecules → components/molecules}/PriceRange/PriceRange.tsx +0 -0
- package/src/{molecules → components/molecules}/PriceRange/index.ts +0 -0
- package/src/{molecules → components/molecules}/PriceRange/stories/PriceRange.mdx +0 -0
- package/src/{molecules → components/molecules}/PriceRange/stories/PriceRange.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/ProductCard/ProductCard.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductCard/ProductCardActions.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductCard/ProductCardContent.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductCard/ProductCardImage.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductCard/index.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductCard/stories/ProductCard.mdx +0 -0
- package/src/{molecules → components/molecules}/ProductCard/stories/ProductCard.stories.tsx +1 -2
- package/src/{molecules → components/molecules}/ProductTitle/ProductTitle.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductTitle/index.tsx +0 -0
- package/src/{molecules → components/molecules}/ProductTitle/stories/ProductTitle.mdx +0 -0
- package/src/{molecules → components/molecules}/ProductTitle/stories/ProductTitle.stories.tsx +3 -3
- package/src/{molecules → components/molecules}/QuantitySelector/QuantitySelector.tsx +2 -2
- package/src/{molecules → components/molecules}/QuantitySelector/index.ts +0 -0
- package/src/{molecules → components/molecules}/QuantitySelector/stories/QuantitySelector.mdx +0 -0
- package/src/{molecules → components/molecules}/QuantitySelector/stories/QuantitySelector.stories.tsx +0 -0
- package/src/{molecules → components/molecules}/QuantitySelector/stories/assets/Icons.tsx +0 -0
- package/src/components/molecules/RadioField/RadioField.stories.mdx +38 -0
- package/src/components/molecules/RadioField/styles.scss +12 -0
- package/src/{molecules → components/molecules}/RadioGroup/RadioGroup.tsx +0 -0
- package/src/{molecules → components/molecules}/RadioGroup/RadioOption.tsx +1 -1
- package/src/{molecules → components/molecules}/RadioGroup/index.tsx +0 -0
- package/src/{molecules → components/molecules}/RadioGroup/stories/RadioGroup.mdx +0 -0
- package/src/{molecules → components/molecules}/RadioGroup/stories/RadioGroup.stories.tsx +0 -0
- package/src/{molecules → components/molecules}/RadioGroup/useRadioGroup.ts +0 -0
- package/src/{molecules → components/molecules}/SearchInput/SearchInput.tsx +2 -3
- package/src/{molecules → components/molecules}/SearchInput/index.ts +0 -0
- package/src/{molecules → components/molecules}/SearchInput/stories/SearchInput.mdx +0 -0
- package/src/{molecules → components/molecules}/SearchInput/stories/SearchInput.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/SearchInput/stories/assets/CustomIcon.tsx +0 -0
- package/src/{molecules → components/molecules}/SkuSelector/SkuSelector.tsx +3 -2
- package/src/{molecules → components/molecules}/SkuSelector/index.tsx +0 -0
- package/src/{molecules → components/molecules}/SkuSelector/stories/SkuSelector.mdx +0 -0
- package/src/{molecules → components/molecules}/SkuSelector/stories/SkuSelector.stories.tsx +1 -1
- package/src/{molecules → components/molecules}/Table/Table.tsx +0 -0
- package/src/{molecules → components/molecules}/Table/TableBody.tsx +0 -0
- package/src/{molecules → components/molecules}/Table/TableCell.tsx +0 -0
- package/src/{molecules → components/molecules}/Table/TableFooter.tsx +0 -0
- package/src/{molecules → components/molecules}/Table/TableHead.tsx +0 -0
- package/src/{molecules → components/molecules}/Table/TableRow.tsx +0 -0
- package/src/{molecules → components/molecules}/Table/index.ts +0 -0
- package/src/{molecules → components/molecules}/Table/stories/Table.mdx +0 -0
- package/src/{molecules → components/molecules}/Table/stories/Table.stories.tsx +0 -0
- package/src/components/molecules/Tag/Tag.stories.mdx +31 -0
- package/src/components/molecules/Tag/styles.scss +99 -0
- package/src/{organisms → components/organisms}/Hero/Hero.tsx +0 -0
- package/src/{organisms → components/organisms}/Hero/HeroHeading.tsx +0 -0
- package/src/{organisms → components/organisms}/Hero/HeroImage.tsx +0 -0
- package/src/{organisms → components/organisms}/Hero/index.tsx +0 -0
- package/src/{organisms → components/organisms}/Hero/stories/Hero.mdx +0 -0
- package/src/{organisms → components/organisms}/Hero/stories/Hero.stories.tsx +1 -1
- package/src/{organisms → components/organisms}/OutOfStock/OutOfStock.tsx +0 -0
- package/src/{organisms → components/organisms}/OutOfStock/OutOfStockMessage.tsx +0 -0
- package/src/{organisms → components/organisms}/OutOfStock/OutOfStockTitle.tsx +0 -0
- package/src/{organisms → components/organisms}/OutOfStock/index.tsx +0 -0
- package/src/{organisms → components/organisms}/OutOfStock/stories/OutOfStock.mdx +0 -0
- package/src/{organisms → components/organisms}/OutOfStock/stories/OutOfStock.stories.tsx +1 -1
- package/src/{organisms → components/organisms}/Tiles/Tile.tsx +0 -0
- package/src/{organisms → components/organisms}/Tiles/Tiles.tsx +0 -0
- package/src/{organisms → components/organisms}/Tiles/index.ts +0 -0
- package/src/{organisms → components/organisms}/Tiles/stories/Tiles.mdx +0 -0
- package/src/{organisms → components/organisms}/Tiles/stories/Tiles.stories.tsx +0 -0
- package/src/index.ts +97 -99
- package/src/styles/base.scss +3 -0
- package/src/styles/components.scss +10 -0
- package/src/styles/global.scss +4 -0
- package/src/styles/reset.scss +54 -0
- package/src/styles/utilities.scss +75 -0
- package/src/typings/utils.d.ts +2 -2
- package/dist/assets/index.d.ts +0 -2
- package/dist/assets/index.js +0 -3
- package/dist/assets/index.js.map +0 -1
- package/src/atoms/Badge/Badge.test.tsx +0 -23
- package/src/atoms/Badge/Badge.tsx +0 -23
- package/src/atoms/Badge/index.ts +0 -2
- package/src/atoms/Badge/stories/Badge.mdx +0 -18
- package/src/atoms/Badge/stories/Badge.stories.tsx +0 -37
- package/src/atoms/Button/Button.test.tsx +0 -12
- package/src/atoms/Button/Button.tsx +0 -23
- package/src/atoms/Button/index.ts +0 -2
- package/src/atoms/Button/stories/Button.mdx +0 -18
- package/src/atoms/Button/stories/Button.stories.tsx +0 -36
- package/src/atoms/Checkbox/Checkbox.test.tsx +0 -65
- package/src/atoms/Checkbox/Checkbox.tsx +0 -27
- package/src/atoms/Checkbox/index.ts +0 -2
- package/src/atoms/Checkbox/stories/Checkbox.mdx +0 -18
- package/src/atoms/Checkbox/stories/Checkbox.stories.tsx +0 -65
- package/src/atoms/Icon/Icon.test.tsx +0 -43
- package/src/atoms/Icon/Icon.tsx +0 -26
- package/src/atoms/Icon/index.ts +0 -2
- package/src/atoms/Icon/stories/Icon.mdx +0 -18
- package/src/atoms/Icon/stories/Icon.stories.tsx +0 -40
- package/src/atoms/Icon/stories/assets/ShoppingCart.tsx +0 -23
- package/src/atoms/Incentive/Incentive.test.tsx +0 -36
- package/src/atoms/Input/Input.test.tsx +0 -73
- package/src/atoms/Label/Label.test.tsx +0 -71
- package/src/atoms/Label/Label.tsx +0 -22
- package/src/atoms/Label/index.ts +0 -2
- package/src/atoms/Label/stories/Label.mdx +0 -18
- package/src/atoms/Label/stories/Label.stories.tsx +0 -30
- package/src/atoms/Link/Link.test.tsx +0 -53
- package/src/atoms/List/List.test.tsx +0 -195
- package/src/atoms/Overlay/Overlay.test.tsx +0 -23
- package/src/atoms/Popover/Popover.test.tsx +0 -39
- package/src/atoms/Price/Price.test.tsx +0 -63
- package/src/atoms/Radio/Radio.test.tsx +0 -59
- package/src/atoms/Radio/Radio.tsx +0 -24
- package/src/atoms/Radio/index.ts +0 -2
- package/src/atoms/Radio/stories/Radio.mdx +0 -18
- package/src/atoms/Radio/stories/Radio.stories.tsx +0 -41
- package/src/atoms/Select/Select.test.tsx +0 -71
- package/src/atoms/Skeleton/Skeleton.test.tsx +0 -13
- package/src/atoms/Slider/Slider.test.tsx +0 -32
- package/src/atoms/Spinner/Spinner.test.tsx +0 -12
- package/src/atoms/TextArea/TextArea.test.tsx +0 -77
- package/src/hooks/useSlider/useSlider.test.ts +0 -176
- package/src/molecules/Accordion/Accordion.test.tsx +0 -226
- package/src/molecules/AggregateRating/AggregateRating.test.tsx +0 -87
- package/src/molecules/Alert/Alert.test.tsx +0 -23
- package/src/molecules/Banner/Banner.test.tsx +0 -67
- package/src/molecules/Breadcrumb/Breadcrumb.test.tsx +0 -124
- package/src/molecules/Bullets/Bullets.test.tsx +0 -128
- package/src/molecules/Card/Card.test.tsx +0 -68
- package/src/molecules/Carousel/Carousel.test.tsx +0 -587
- package/src/molecules/Carousel/hooks/hooks.test.ts +0 -109
- package/src/molecules/CartItem/CartItem.test.tsx +0 -79
- package/src/molecules/Dropdown/Dropdown.test.tsx +0 -275
- package/src/molecules/Form/Form.test.tsx +0 -61
- package/src/molecules/Gift/Gift.test.tsx +0 -53
- package/src/molecules/IconButton/IconButton.test.tsx +0 -31
- package/src/molecules/IconButton/IconButton.tsx +0 -35
- package/src/molecules/IconButton/index.tsx +0 -2
- package/src/molecules/IconButton/stories/IconButton.mdx +0 -27
- package/src/molecules/IconButton/stories/IconButton.stories.tsx +0 -35
- package/src/molecules/LoadingButton/LoadingButton.test.tsx +0 -14
- package/src/molecules/Modal/Modal.test.tsx +0 -241
- package/src/molecules/OrderSummary/OrderSummary.test.tsx +0 -103
- package/src/molecules/PaymentMethods/PaymentMethods.test.tsx +0 -37
- package/src/molecules/PriceRange/PriceRange.test.tsx +0 -70
- package/src/molecules/ProductCard/ProductCard.test.tsx +0 -75
- package/src/molecules/QuantitySelector/QuantitySelector.test.tsx +0 -93
- package/src/molecules/RadioGroup/RadioGroup.test.tsx +0 -107
- package/src/molecules/SearchInput/SearchInput.test.tsx +0 -34
- package/src/molecules/SkuSelector/SkuSelector.test.tsx +0 -42
- package/src/molecules/Table/Table.test.tsx +0 -233
- package/src/organisms/Hero/Hero.test.tsx +0 -60
- package/src/organisms/OutOfStock/OutOfStock.test.tsx +0 -122
- package/src/setupTests.ts +0 -7
- package/src/utils/toHaveNoIncomplete.ts +0 -76
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react'
|
|
3
|
-
import { axe } from 'jest-axe'
|
|
4
|
-
|
|
5
|
-
import TextArea from './TextArea'
|
|
6
|
-
|
|
7
|
-
const testId = 'store-textarea'
|
|
8
|
-
|
|
9
|
-
describe('TextArea', () => {
|
|
10
|
-
it('data-fs-textarea is present', () => {
|
|
11
|
-
const { getByTestId } = render(<TextArea testId={testId} />)
|
|
12
|
-
|
|
13
|
-
expect(getByTestId(testId)).toHaveAttribute('data-fs-textarea')
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('state is error', () => {
|
|
17
|
-
const { getByTestId } = render(<TextArea testId={testId} variant="error" />)
|
|
18
|
-
|
|
19
|
-
expect(getByTestId(testId)).toHaveAttribute('data-error', 'true')
|
|
20
|
-
expect(getByTestId(testId)).not.toHaveAttribute('data-success')
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('state is success', () => {
|
|
24
|
-
const { getByTestId } = render(
|
|
25
|
-
<TextArea testId={testId} variant="success" />
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
expect(getByTestId(testId)).toHaveAttribute('data-success', 'true')
|
|
29
|
-
expect(getByTestId(testId)).not.toHaveAttribute('data-error')
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
describe('Accessibility', () => {
|
|
33
|
-
it('should have no violations using aria-label', async () => {
|
|
34
|
-
const { container } = render(
|
|
35
|
-
<TextArea
|
|
36
|
-
aria-label="label textarea for test"
|
|
37
|
-
testId="store-textarea"
|
|
38
|
-
/>
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
expect(await axe(container)).toHaveNoViolations()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('should have no violations using aria-labelledby', async () => {
|
|
45
|
-
const { container } = render(
|
|
46
|
-
<>
|
|
47
|
-
<span id="label">My test label</span>
|
|
48
|
-
<TextArea aria-labelledby="label" testId="store-textarea" />
|
|
49
|
-
</>
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
expect(await axe(container)).toHaveNoViolations()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('should have no violations using placeholder', async () => {
|
|
56
|
-
const { container } = render(
|
|
57
|
-
<TextArea
|
|
58
|
-
placeholder="Accessibility placeholder"
|
|
59
|
-
testId="store-textarea"
|
|
60
|
-
/>
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
expect(await axe(container)).toHaveNoViolations()
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it('should have no violations using id with explicit label', async () => {
|
|
67
|
-
const { container } = render(
|
|
68
|
-
<>
|
|
69
|
-
<label htmlFor="textarea">My test label</label>
|
|
70
|
-
<TextArea id="textarea" testId="store-textarea" />
|
|
71
|
-
</>
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
expect(await axe(container)).toHaveNoViolations()
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
})
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { renderHook, act } from '@testing-library/react-hooks'
|
|
2
|
-
|
|
3
|
-
import useSlider from './useSlider'
|
|
4
|
-
|
|
5
|
-
describe('useSlider', () => {
|
|
6
|
-
it('should initialize sliderState correctly', () => {
|
|
7
|
-
const expectedSliderState = {
|
|
8
|
-
currentItem: 0,
|
|
9
|
-
currentPage: 0,
|
|
10
|
-
sliding: false,
|
|
11
|
-
slideDirection: 'next',
|
|
12
|
-
totalItems: 5,
|
|
13
|
-
itemsPerPage: 2,
|
|
14
|
-
totalPages: 3,
|
|
15
|
-
infinite: false,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const { result: returnValue } = renderHook(() =>
|
|
19
|
-
useSlider({
|
|
20
|
-
totalItems: 5,
|
|
21
|
-
itemsPerPage: 2,
|
|
22
|
-
infiniteMode: false,
|
|
23
|
-
})
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
const receivedSliderState = returnValue.current.sliderState
|
|
27
|
-
|
|
28
|
-
expect(receivedSliderState).toEqual(expectedSliderState)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
it('should go to next page and update state accordingly', () => {
|
|
32
|
-
const { result } = renderHook(() =>
|
|
33
|
-
useSlider({
|
|
34
|
-
totalItems: 5,
|
|
35
|
-
itemsPerPage: 2,
|
|
36
|
-
infiniteMode: false,
|
|
37
|
-
})
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
const finalState = {
|
|
41
|
-
currentItem: 2,
|
|
42
|
-
currentPage: 1,
|
|
43
|
-
sliding: true,
|
|
44
|
-
slideDirection: 'next',
|
|
45
|
-
totalItems: 5,
|
|
46
|
-
itemsPerPage: 2,
|
|
47
|
-
totalPages: 3,
|
|
48
|
-
infinite: false,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const { sliderDispatch } = result.current
|
|
52
|
-
|
|
53
|
-
act(() => {
|
|
54
|
-
sliderDispatch({ type: 'NEXT_PAGE' })
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
expect(result.current.sliderState).toEqual(finalState)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('should go to previous page and update state accordingly', () => {
|
|
61
|
-
const { result } = renderHook(() =>
|
|
62
|
-
useSlider({
|
|
63
|
-
totalItems: 5,
|
|
64
|
-
itemsPerPage: 2,
|
|
65
|
-
infiniteMode: false,
|
|
66
|
-
})
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
const { sliderDispatch } = result.current
|
|
70
|
-
|
|
71
|
-
act(() => {
|
|
72
|
-
sliderDispatch({ type: 'PREVIOUS_PAGE' })
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
expect(result.current.sliderState).toEqual({
|
|
76
|
-
currentItem: 4,
|
|
77
|
-
currentPage: 2,
|
|
78
|
-
sliding: true,
|
|
79
|
-
slideDirection: 'previous',
|
|
80
|
-
totalItems: 5,
|
|
81
|
-
itemsPerPage: 2,
|
|
82
|
-
totalPages: 3,
|
|
83
|
-
infinite: false,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
act(() => {
|
|
87
|
-
sliderDispatch({ type: 'PREVIOUS_PAGE' })
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
expect(result.current.sliderState).toEqual({
|
|
91
|
-
currentItem: 2,
|
|
92
|
-
currentPage: 1,
|
|
93
|
-
sliding: true,
|
|
94
|
-
slideDirection: 'previous',
|
|
95
|
-
totalItems: 5,
|
|
96
|
-
itemsPerPage: 2,
|
|
97
|
-
totalPages: 3,
|
|
98
|
-
infinite: false,
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should go to a certain page and update state accordingly', () => {
|
|
103
|
-
const { result } = renderHook(() =>
|
|
104
|
-
useSlider({
|
|
105
|
-
totalItems: 5,
|
|
106
|
-
itemsPerPage: 2,
|
|
107
|
-
infiniteMode: false,
|
|
108
|
-
})
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
const { sliderDispatch } = result.current
|
|
112
|
-
|
|
113
|
-
act(() => {
|
|
114
|
-
sliderDispatch({
|
|
115
|
-
type: 'GO_TO_PAGE',
|
|
116
|
-
payload: {
|
|
117
|
-
pageIndex: 1,
|
|
118
|
-
shouldSlide: true,
|
|
119
|
-
},
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
expect(result.current.sliderState).toEqual({
|
|
124
|
-
currentItem: 2,
|
|
125
|
-
currentPage: 1,
|
|
126
|
-
sliding: true,
|
|
127
|
-
slideDirection: 'next',
|
|
128
|
-
totalItems: 5,
|
|
129
|
-
itemsPerPage: 2,
|
|
130
|
-
totalPages: 3,
|
|
131
|
-
infinite: false,
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
act(() => {
|
|
135
|
-
sliderDispatch({
|
|
136
|
-
type: 'GO_TO_PAGE',
|
|
137
|
-
payload: {
|
|
138
|
-
pageIndex: 2,
|
|
139
|
-
shouldSlide: true,
|
|
140
|
-
},
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
expect(result.current.sliderState).toEqual({
|
|
145
|
-
currentItem: 4,
|
|
146
|
-
currentPage: 2,
|
|
147
|
-
sliding: true,
|
|
148
|
-
slideDirection: 'next',
|
|
149
|
-
totalItems: 5,
|
|
150
|
-
itemsPerPage: 2,
|
|
151
|
-
totalPages: 3,
|
|
152
|
-
infinite: false,
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
act(() => {
|
|
156
|
-
sliderDispatch({
|
|
157
|
-
type: 'GO_TO_PAGE',
|
|
158
|
-
payload: {
|
|
159
|
-
pageIndex: 0,
|
|
160
|
-
shouldSlide: true,
|
|
161
|
-
},
|
|
162
|
-
})
|
|
163
|
-
})
|
|
164
|
-
|
|
165
|
-
expect(result.current.sliderState).toEqual({
|
|
166
|
-
currentItem: 0,
|
|
167
|
-
currentPage: 0,
|
|
168
|
-
sliding: true,
|
|
169
|
-
slideDirection: 'previous',
|
|
170
|
-
totalItems: 5,
|
|
171
|
-
itemsPerPage: 2,
|
|
172
|
-
totalPages: 3,
|
|
173
|
-
infinite: false,
|
|
174
|
-
})
|
|
175
|
-
})
|
|
176
|
-
})
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { render, fireEvent, cleanup } from '@testing-library/react'
|
|
2
|
-
import { axe } from 'jest-axe'
|
|
3
|
-
import React, { useState } from 'react'
|
|
4
|
-
|
|
5
|
-
import Accordion from './Accordion'
|
|
6
|
-
import AccordionItem from './AccordionItem'
|
|
7
|
-
import AccordionButton from './AccordionButton'
|
|
8
|
-
import AccordionPanel from './AccordionPanel'
|
|
9
|
-
|
|
10
|
-
const TestAccordion = () => {
|
|
11
|
-
const [indices, setIndices] = useState<number[]>([])
|
|
12
|
-
const onChange = (index: number) => {
|
|
13
|
-
if (indices.includes(index)) {
|
|
14
|
-
setIndices(indices.filter((currentIndex) => currentIndex !== index))
|
|
15
|
-
} else {
|
|
16
|
-
setIndices([...indices, index])
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Accordion
|
|
22
|
-
aria-label="test accordion"
|
|
23
|
-
indices={indices}
|
|
24
|
-
onChange={onChange}
|
|
25
|
-
>
|
|
26
|
-
<AccordionItem>
|
|
27
|
-
<AccordionButton>Clothing</AccordionButton>
|
|
28
|
-
<AccordionPanel>
|
|
29
|
-
<ul>
|
|
30
|
-
<li>
|
|
31
|
-
<a href="/">Shorts</a>
|
|
32
|
-
</li>
|
|
33
|
-
<li>
|
|
34
|
-
<a href="/">Sweatshirt</a>
|
|
35
|
-
</li>
|
|
36
|
-
<li>
|
|
37
|
-
<a href="/">Tank tops</a>
|
|
38
|
-
</li>
|
|
39
|
-
</ul>
|
|
40
|
-
</AccordionPanel>
|
|
41
|
-
</AccordionItem>
|
|
42
|
-
|
|
43
|
-
<AccordionItem>
|
|
44
|
-
<AccordionButton>Sale</AccordionButton>
|
|
45
|
-
<AccordionPanel>
|
|
46
|
-
<ul>
|
|
47
|
-
<li>
|
|
48
|
-
<a href="/">Smartphones</a>
|
|
49
|
-
</li>
|
|
50
|
-
<li>
|
|
51
|
-
<a href="/">TVs</a>
|
|
52
|
-
</li>
|
|
53
|
-
</ul>
|
|
54
|
-
</AccordionPanel>
|
|
55
|
-
</AccordionItem>
|
|
56
|
-
</Accordion>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
describe('Accordion', () => {
|
|
61
|
-
let accordion: HTMLElement
|
|
62
|
-
let items: HTMLElement[]
|
|
63
|
-
let buttons: HTMLElement[]
|
|
64
|
-
let panels: HTMLElement[]
|
|
65
|
-
|
|
66
|
-
beforeEach(() => {
|
|
67
|
-
const { getByTestId, getAllByTestId } = render(<TestAccordion />)
|
|
68
|
-
|
|
69
|
-
accordion = getByTestId('store-accordion')
|
|
70
|
-
items = getAllByTestId('store-accordion-item')
|
|
71
|
-
buttons = getAllByTestId('store-accordion-button')
|
|
72
|
-
panels = getAllByTestId('store-accordion-panel')
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
afterEach(cleanup)
|
|
76
|
-
|
|
77
|
-
it('should show panel specified by `indices`', () => {
|
|
78
|
-
const { getAllByTestId } = render(
|
|
79
|
-
<Accordion indices={[1]} onChange={() => null}>
|
|
80
|
-
<AccordionItem>
|
|
81
|
-
<AccordionButton />
|
|
82
|
-
<AccordionPanel testId="store-accordion-panel-mock" />
|
|
83
|
-
</AccordionItem>
|
|
84
|
-
<AccordionItem>
|
|
85
|
-
<AccordionButton />
|
|
86
|
-
<AccordionPanel testId="store-accordion-panel-mock" />
|
|
87
|
-
</AccordionItem>
|
|
88
|
-
</Accordion>
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
const panelsMock = getAllByTestId('store-accordion-panel-mock')
|
|
92
|
-
|
|
93
|
-
expect(panelsMock[0]).not.toBeVisible()
|
|
94
|
-
expect(panelsMock[1]).toBeVisible()
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('should prevent duplicate IDs when using the `prefixID` attribute', () => {
|
|
98
|
-
const { getAllByTestId } = render(
|
|
99
|
-
<>
|
|
100
|
-
<Accordion indices={[]} onChange={() => null}>
|
|
101
|
-
<AccordionItem prefixId="filter">
|
|
102
|
-
<AccordionButton testId="data-accordion-button" />
|
|
103
|
-
<AccordionPanel testId="data-accordion-panel" />
|
|
104
|
-
</AccordionItem>
|
|
105
|
-
</Accordion>
|
|
106
|
-
<Accordion indices={[]} onChange={() => null}>
|
|
107
|
-
<AccordionItem prefixId="footer">
|
|
108
|
-
<AccordionButton testId="data-accordion-button" />
|
|
109
|
-
<AccordionPanel testId="data-accordion-panel" />
|
|
110
|
-
</AccordionItem>
|
|
111
|
-
</Accordion>
|
|
112
|
-
</>
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
const allPanels = getAllByTestId('data-accordion-panel')
|
|
116
|
-
const allButtons = getAllByTestId('data-accordion-button')
|
|
117
|
-
|
|
118
|
-
// Attributes
|
|
119
|
-
expect(allPanels[0]).toHaveAttribute('id', 'filter-panel--0')
|
|
120
|
-
expect(allPanels[1]).toHaveAttribute('id', 'footer-panel--0')
|
|
121
|
-
expect(allButtons[0]).toHaveAttribute('id', 'filter-button--0')
|
|
122
|
-
expect(allButtons[1]).toHaveAttribute('id', 'footer-button--0')
|
|
123
|
-
|
|
124
|
-
// Equality assertions
|
|
125
|
-
expect(allPanels[0].id).not.toEqual(allPanels[1].id)
|
|
126
|
-
expect(allButtons[0].id).not.toEqual(allButtons[1].id)
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
describe('Data attributes', () => {
|
|
130
|
-
it('`Accordion` component should have `data-fs-accordion` attribute', () => {
|
|
131
|
-
expect(accordion).toHaveAttribute('data-fs-accordion')
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
it('`AccordionItem` component should have `data-accordion-item` attribute', () => {
|
|
135
|
-
for (const item of items) {
|
|
136
|
-
expect(item).toHaveAttribute('data-accordion-item')
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('`AccordionButton` component should have `data-accordion-button` attribute', () => {
|
|
141
|
-
for (const button of buttons) {
|
|
142
|
-
expect(button).toHaveAttribute('data-accordion-button')
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
it('`AccordionPanel` component should have `data-accordion-panel` attribute', () => {
|
|
147
|
-
for (const panel of panels) {
|
|
148
|
-
expect(panel).toHaveAttribute('data-accordion-panel')
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
describe('User actions', () => {
|
|
154
|
-
it('clicking item should call `onChange` function', () => {
|
|
155
|
-
const mockOnChange = jest.fn()
|
|
156
|
-
const { getByTestId } = render(
|
|
157
|
-
<Accordion onChange={mockOnChange} indices={[]}>
|
|
158
|
-
<AccordionItem>
|
|
159
|
-
<AccordionButton testId="store-accordion-button-mock" />
|
|
160
|
-
</AccordionItem>
|
|
161
|
-
</Accordion>
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
const button = getByTestId('store-accordion-button-mock')
|
|
165
|
-
|
|
166
|
-
fireEvent.click(button)
|
|
167
|
-
expect(mockOnChange).toHaveBeenCalledTimes(1)
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it('should move focus to the next focusable button on `ArrowDown` press', () => {
|
|
171
|
-
buttons[1].focus()
|
|
172
|
-
expect(buttons[1]).toHaveFocus()
|
|
173
|
-
fireEvent.keyDown(document.activeElement!, { key: 'ArrowDown' })
|
|
174
|
-
expect(buttons[0]).toHaveFocus()
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it('should move focus to the previous focusable button on `ArrowUp` press', () => {
|
|
178
|
-
buttons[1].focus()
|
|
179
|
-
expect(buttons[1]).toHaveFocus()
|
|
180
|
-
fireEvent.keyDown(document.activeElement!, { key: 'ArrowUp' })
|
|
181
|
-
expect(buttons[0]).toHaveFocus()
|
|
182
|
-
})
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
describe('Accessibility', () => {
|
|
186
|
-
// WAI-ARIA tests
|
|
187
|
-
// https://www.w3.org/TR/wai-aria-practices-1.2/#accordion
|
|
188
|
-
it('should not have violations', async () => {
|
|
189
|
-
expect(await axe(document.body)).toHaveNoViolations()
|
|
190
|
-
|
|
191
|
-
// Open a panel and check again
|
|
192
|
-
fireEvent.click(buttons[0])
|
|
193
|
-
expect(await axe(document.body)).toHaveNoViolations()
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
it('`role` should be set to `region` for panel elements', () => {
|
|
197
|
-
for (const panel of panels) {
|
|
198
|
-
expect(panel).toHaveAttribute('role', 'region')
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
it('`aria-labelledby` for panel elements should point to the corresponding button', () => {
|
|
203
|
-
panels.forEach((panel, index) => {
|
|
204
|
-
expect(panel).toHaveAttribute(
|
|
205
|
-
'aria-labelledby',
|
|
206
|
-
buttons[index].getAttribute('id')
|
|
207
|
-
)
|
|
208
|
-
})
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
it('`aria-controls` for button elements should point to the corresponding panel', () => {
|
|
212
|
-
buttons.forEach((button, index) => {
|
|
213
|
-
expect(button).toHaveAttribute(
|
|
214
|
-
'aria-controls',
|
|
215
|
-
panels[index].getAttribute('id')
|
|
216
|
-
)
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
it('`aria-expanded` should be true only for active button', () => {
|
|
221
|
-
expect(buttons[0]).toHaveAttribute('aria-expanded', 'false')
|
|
222
|
-
fireEvent.click(buttons[0])
|
|
223
|
-
expect(buttons[0]).toHaveAttribute('aria-expanded', 'true')
|
|
224
|
-
})
|
|
225
|
-
})
|
|
226
|
-
})
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
2
|
-
import { axe } from 'jest-axe'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import AggregateRating from './AggregateRating'
|
|
6
|
-
|
|
7
|
-
const fillCheck = (value: number) => {
|
|
8
|
-
if (value >= 1) {
|
|
9
|
-
return 'full'
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (0 < value && value < 1) {
|
|
13
|
-
return 'partial'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return 'empty'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
describe('AggregateRating', () => {
|
|
20
|
-
it('`data-fs-aggregate-rating` is present', () => {
|
|
21
|
-
const { getByTestId } = render(
|
|
22
|
-
<AggregateRating value={2}>
|
|
23
|
-
<span />
|
|
24
|
-
<span />
|
|
25
|
-
<span />
|
|
26
|
-
<span />
|
|
27
|
-
<span />
|
|
28
|
-
</AggregateRating>
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
expect(getByTestId('store-aggregate-rating')).toHaveAttribute(
|
|
32
|
-
'data-fs-aggregate-rating'
|
|
33
|
-
)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('has the correct aggregate rating item data attribute', () => {
|
|
37
|
-
const { queryAllByTestId, rerender } = render(
|
|
38
|
-
<AggregateRating value={2}>
|
|
39
|
-
<span />
|
|
40
|
-
</AggregateRating>
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
// Test 5 random values and sizes in Aggregate Rating component.
|
|
44
|
-
for (let i = 1; i <= 5; i += 1) {
|
|
45
|
-
// Random value between 1 and 10
|
|
46
|
-
const numberOfElements = Math.ceil(Math.random() * 10)
|
|
47
|
-
const value = parseFloat((Math.random() * numberOfElements).toFixed(1))
|
|
48
|
-
|
|
49
|
-
rerender(
|
|
50
|
-
<AggregateRating value={value}>
|
|
51
|
-
{Array.from({ length: numberOfElements })}
|
|
52
|
-
</AggregateRating>
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
const ratingItems = queryAllByTestId('store-aggregate-rating-item')
|
|
56
|
-
|
|
57
|
-
// Validate if it's rendering with the correct number of ratings.
|
|
58
|
-
expect(ratingItems).toHaveLength(numberOfElements)
|
|
59
|
-
|
|
60
|
-
// Validate if each rating element has the correct attribute.
|
|
61
|
-
for (
|
|
62
|
-
let currentItemNumber = 0;
|
|
63
|
-
currentItemNumber < numberOfElements;
|
|
64
|
-
currentItemNumber += 1
|
|
65
|
-
) {
|
|
66
|
-
expect(ratingItems[currentItemNumber]).toHaveAttribute(
|
|
67
|
-
'data-fs-aggregate-rating-item',
|
|
68
|
-
fillCheck(value - currentItemNumber)
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('AXE Test', async () => {
|
|
75
|
-
render(
|
|
76
|
-
<AggregateRating value={3}>
|
|
77
|
-
<span />
|
|
78
|
-
<span />
|
|
79
|
-
<span />
|
|
80
|
-
<span />
|
|
81
|
-
<span />
|
|
82
|
-
</AggregateRating>
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
expect(await axe(document.body)).toHaveNoViolations()
|
|
86
|
-
})
|
|
87
|
-
})
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
2
|
-
import { axe } from 'jest-axe'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import Alert from './Alert'
|
|
6
|
-
|
|
7
|
-
describe('Alert', () => {
|
|
8
|
-
describe('Data attributes', () => {
|
|
9
|
-
it('should have `data-fs-alert` attribute', () => {
|
|
10
|
-
const { getByTestId } = render(<Alert>Testing</Alert>)
|
|
11
|
-
|
|
12
|
-
expect(getByTestId('store-alert')).toHaveAttribute('data-fs-alert')
|
|
13
|
-
})
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
describe('Accessibility', () => {
|
|
17
|
-
it('should have no violations', async () => {
|
|
18
|
-
const { getByTestId } = render(<Alert />)
|
|
19
|
-
|
|
20
|
-
expect(await axe(getByTestId('store-alert'))).toHaveNoViolations()
|
|
21
|
-
})
|
|
22
|
-
})
|
|
23
|
-
})
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react'
|
|
2
|
-
import { axe } from 'jest-axe'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import Banner from './Banner'
|
|
6
|
-
import BannerImage from './BannerImage'
|
|
7
|
-
import BannerContent from './BannerContent'
|
|
8
|
-
import BannerLink from './BannerLink'
|
|
9
|
-
|
|
10
|
-
const BannerTest = () => {
|
|
11
|
-
return (
|
|
12
|
-
<Banner data-custom-attribute>
|
|
13
|
-
<BannerImage>
|
|
14
|
-
<img
|
|
15
|
-
alt="A person with hands on the pocket, carrying a round straw bag"
|
|
16
|
-
src="https://storecomponents.vtex.app/assets/fit-in/1280x613/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Fassets%2Fvtex.file-manager-graphql%2Fimages%2Fedce348c-068c-4fb9-91f2-7d235d596e0f___b2822f893b14f87337d08f07f0e520ab.jpg"
|
|
17
|
-
/>
|
|
18
|
-
</BannerImage>
|
|
19
|
-
<BannerContent>
|
|
20
|
-
<div>
|
|
21
|
-
<h3>Get yo know our next release</h3>
|
|
22
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
23
|
-
</div>
|
|
24
|
-
<BannerLink>Shop now</BannerLink>
|
|
25
|
-
</BannerContent>
|
|
26
|
-
</Banner>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
describe('Banner', () => {
|
|
31
|
-
describe('Data attributes', () => {
|
|
32
|
-
const { getByTestId } = render(<BannerTest />)
|
|
33
|
-
|
|
34
|
-
const banner = getByTestId('store-banner')
|
|
35
|
-
const bannerImage = getByTestId('store-banner-image')
|
|
36
|
-
const bannerContent = getByTestId('store-banner-content')
|
|
37
|
-
const bannerLink = getByTestId('store-banner-link')
|
|
38
|
-
|
|
39
|
-
it('`Banner` component should have `data-fs-banner` attribute', () => {
|
|
40
|
-
expect(banner).toHaveAttribute('data-fs-banner')
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('`Banner` component should have custom data attribute `data-custom-attribute`', () => {
|
|
44
|
-
expect(banner).toHaveAttribute('data-custom-attribute')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('`BannerImage` component should have `data-banner-image` attribute', () => {
|
|
48
|
-
expect(bannerImage).toHaveAttribute('data-banner-image')
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('`BannerContent` component should have `data-banner-content` attribute', () => {
|
|
52
|
-
expect(bannerContent).toHaveAttribute('data-banner-content')
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
it('`BannerLink` component should have `data-banner-link` attribute', () => {
|
|
56
|
-
expect(bannerLink).toHaveAttribute('data-banner-link')
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
describe('Accessibility', () => {
|
|
61
|
-
it('should have no violations', async () => {
|
|
62
|
-
const { getByTestId } = render(<BannerTest />)
|
|
63
|
-
|
|
64
|
-
expect(await axe(getByTestId('store-banner'))).toHaveNoViolations()
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
})
|