@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.
Files changed (317) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/assets/ShoppingCart.d.ts +2 -2
  3. package/dist/assets/ShoppingCart.js.map +1 -1
  4. package/dist/assets/X.d.ts +2 -2
  5. package/dist/assets/X.js.map +1 -1
  6. package/package.json +30 -37
  7. package/src/assets/ShoppingCart.tsx +50 -0
  8. package/src/assets/X.tsx +38 -0
  9. package/src/base/layout.scss +78 -0
  10. package/src/base/tokens.scss +274 -0
  11. package/src/base/typography.scss +64 -0
  12. package/src/components/atoms/Badge/Badge.stories.mdx +156 -0
  13. package/src/components/atoms/Badge/styles.scss +209 -0
  14. package/src/components/atoms/Button/Button.stories.mdx +110 -0
  15. package/src/components/atoms/Button/styles.scss +316 -0
  16. package/src/components/atoms/Checkbox/styles.scss +155 -0
  17. package/src/{atoms → components/atoms}/Incentive/Incentive.tsx +0 -0
  18. package/src/{atoms → components/atoms}/Incentive/index.tsx +0 -0
  19. package/src/{atoms → components/atoms}/Incentive/stories/Incentive.mdx +0 -0
  20. package/src/{atoms → components/atoms}/Incentive/stories/Incentive.stories.tsx +0 -0
  21. package/src/{atoms → components/atoms}/Incentive/stories/assets/Icons.tsx +0 -0
  22. package/src/{atoms → components/atoms}/Input/Input.tsx +0 -0
  23. package/src/{atoms → components/atoms}/Input/index.ts +0 -0
  24. package/src/{atoms → components/atoms}/Input/stories/Input.mdx +0 -0
  25. package/src/{atoms → components/atoms}/Input/stories/Input.stories.tsx +1 -1
  26. package/src/components/atoms/Label/Label.stories.mdx +65 -0
  27. package/src/{atoms → components/atoms}/Link/Link.tsx +1 -1
  28. package/src/{atoms → components/atoms}/Link/index.tsx +0 -0
  29. package/src/{atoms → components/atoms}/Link/stories/Link.mdx +0 -0
  30. package/src/{atoms → components/atoms}/Link/stories/Link.stories.tsx +0 -0
  31. package/src/{atoms → components/atoms}/List/List.tsx +0 -0
  32. package/src/{atoms → components/atoms}/List/index.ts +0 -0
  33. package/src/{atoms → components/atoms}/List/stories/List.mdx +0 -0
  34. package/src/{atoms → components/atoms}/List/stories/List.stories.tsx +1 -1
  35. package/src/{atoms → components/atoms}/Overlay/Overlay.tsx +0 -0
  36. package/src/{atoms → components/atoms}/Overlay/index.ts +0 -0
  37. package/src/{atoms → components/atoms}/Overlay/stories/Overlay.mdx +0 -0
  38. package/src/{atoms → components/atoms}/Overlay/stories/Overlay.stories.tsx +1 -1
  39. package/src/{atoms → components/atoms}/Popover/Popover.tsx +0 -0
  40. package/src/{atoms → components/atoms}/Popover/index.ts +0 -0
  41. package/src/{atoms → components/atoms}/Popover/stories/Popover.mdx +0 -0
  42. package/src/{atoms → components/atoms}/Popover/stories/Popover.stories.tsx +1 -1
  43. package/src/{atoms → components/atoms}/Price/Price.tsx +0 -0
  44. package/src/{atoms → components/atoms}/Price/index.ts +0 -0
  45. package/src/{atoms → components/atoms}/Price/stories/Price.mdx +0 -0
  46. package/src/{atoms → components/atoms}/Price/stories/Price.stories.tsx +1 -1
  47. package/src/components/atoms/Radio/Radio.stories.mdx +101 -0
  48. package/src/components/atoms/Radio/styles.scss +108 -0
  49. package/src/{atoms → components/atoms}/Select/Select.tsx +0 -0
  50. package/src/{atoms → components/atoms}/Select/index.ts +0 -0
  51. package/src/{atoms → components/atoms}/Select/stories/Select.mdx +0 -0
  52. package/src/{atoms → components/atoms}/Select/stories/Select.stories.tsx +1 -1
  53. package/src/{atoms → components/atoms}/Skeleton/Skeleton.tsx +0 -0
  54. package/src/{atoms → components/atoms}/Skeleton/index.ts +0 -0
  55. package/src/{atoms → components/atoms}/Skeleton/stories/Skeleton.mdx +0 -0
  56. package/src/{atoms → components/atoms}/Skeleton/stories/Skeleton.stories.tsx +0 -0
  57. package/src/{atoms → components/atoms}/Slider/Slider.tsx +0 -0
  58. package/src/{atoms → components/atoms}/Slider/index.ts +0 -0
  59. package/src/{atoms → components/atoms}/Slider/stories/Slider.mdx +0 -0
  60. package/src/{atoms → components/atoms}/Slider/stories/Slider.stories.tsx +1 -1
  61. package/src/{atoms → components/atoms}/Spinner/Spinner.tsx +0 -0
  62. package/src/{atoms → components/atoms}/Spinner/index.tsx +0 -0
  63. package/src/{atoms → components/atoms}/Spinner/stories/Spinner.mdx +0 -0
  64. package/src/{atoms → components/atoms}/Spinner/stories/Spinner.stories.tsx +0 -0
  65. package/src/{atoms → components/atoms}/TextArea/TextArea.tsx +0 -0
  66. package/src/{atoms → components/atoms}/TextArea/index.ts +0 -0
  67. package/src/{atoms → components/atoms}/TextArea/stories/TextArea.mdx +0 -0
  68. package/src/{atoms → components/atoms}/TextArea/stories/TextArea.stories.tsx +1 -1
  69. package/src/{molecules → components/molecules}/Accordion/Accordion.tsx +0 -0
  70. package/src/{molecules → components/molecules}/Accordion/AccordionButton.tsx +4 -4
  71. package/src/{molecules → components/molecules}/Accordion/AccordionItem.tsx +1 -1
  72. package/src/{molecules → components/molecules}/Accordion/AccordionPanel.tsx +0 -0
  73. package/src/{molecules → components/molecules}/Accordion/index.ts +0 -0
  74. package/src/{molecules → components/molecules}/Accordion/stories/Accordion.mdx +0 -0
  75. package/src/{molecules → components/molecules}/Accordion/stories/Accordion.stories.tsx +1 -1
  76. package/src/{molecules → components/molecules}/AggregateRating/AggregateRating.tsx +0 -0
  77. package/src/{molecules → components/molecules}/AggregateRating/index.ts +0 -0
  78. package/src/{molecules → components/molecules}/AggregateRating/stories/AggregateRating.mdx +0 -0
  79. package/src/{molecules → components/molecules}/AggregateRating/stories/AggregateRating.stories.tsx +1 -1
  80. package/src/{molecules → components/molecules}/Alert/Alert.tsx +0 -0
  81. package/src/{molecules → components/molecules}/Alert/index.ts +0 -0
  82. package/src/{molecules → components/molecules}/Alert/stories/Alert.mdx +0 -0
  83. package/src/{molecules → components/molecules}/Alert/stories/Alert.stories.tsx +3 -3
  84. package/src/{molecules → components/molecules}/Banner/Banner.tsx +0 -0
  85. package/src/{molecules → components/molecules}/Banner/BannerContent.tsx +0 -0
  86. package/src/{molecules → components/molecules}/Banner/BannerImage.tsx +0 -0
  87. package/src/{molecules → components/molecules}/Banner/BannerLink.tsx +0 -0
  88. package/src/{molecules → components/molecules}/Banner/index.ts +0 -0
  89. package/src/{molecules → components/molecules}/Banner/stories/Banner.mdx +0 -0
  90. package/src/{molecules → components/molecules}/Banner/stories/Banner.stories.tsx +1 -1
  91. package/src/{molecules → components/molecules}/Breadcrumb/Breadcrumb.tsx +0 -0
  92. package/src/{molecules → components/molecules}/Breadcrumb/index.ts +0 -0
  93. package/src/{molecules → components/molecules}/Breadcrumb/stories/Breadcrumb.mdx +0 -0
  94. package/src/{molecules → components/molecules}/Breadcrumb/stories/Breadcrumb.stories.tsx +1 -1
  95. package/src/{molecules → components/molecules}/Bullets/Bullets.tsx +1 -1
  96. package/src/{molecules → components/molecules}/Bullets/index.ts +0 -0
  97. package/src/{molecules → components/molecules}/Bullets/stories/Bullets.mdx +0 -0
  98. package/src/{molecules → components/molecules}/Bullets/stories/Bullets.stories.tsx +1 -1
  99. package/src/{molecules → components/molecules}/Card/Card.tsx +0 -0
  100. package/src/{molecules → components/molecules}/Card/CardActions.tsx +0 -0
  101. package/src/{molecules → components/molecules}/Card/CardContent.tsx +0 -0
  102. package/src/{molecules → components/molecules}/Card/CardImage.tsx +0 -0
  103. package/src/{molecules → components/molecules}/Card/index.tsx +0 -0
  104. package/src/{molecules → components/molecules}/Card/stories/Card.mdx +0 -0
  105. package/src/{molecules → components/molecules}/Card/stories/Card.stories.tsx +5 -5
  106. package/src/{molecules → components/molecules}/Carousel/Arrows.tsx +0 -0
  107. package/src/{molecules → components/molecules}/Carousel/Carousel.tsx +2 -2
  108. package/src/{molecules → components/molecules}/Carousel/CarouselItem.tsx +1 -1
  109. package/src/{molecules → components/molecules}/Carousel/hooks/useSlideVisibility.ts +0 -0
  110. package/src/{molecules → components/molecules}/Carousel/index.ts +0 -0
  111. package/src/{molecules → components/molecules}/Carousel/stories/Carousel.mdx +0 -0
  112. package/src/{molecules → components/molecules}/Carousel/stories/Carousel.stories.tsx +1 -1
  113. package/src/{molecules → components/molecules}/CartItem/CartItem.tsx +0 -0
  114. package/src/{molecules → components/molecules}/CartItem/CartItemActions.tsx +0 -0
  115. package/src/{molecules → components/molecules}/CartItem/CartItemContent.tsx +0 -0
  116. package/src/{molecules → components/molecules}/CartItem/CartItemImage.tsx +0 -0
  117. package/src/{molecules → components/molecules}/CartItem/CartItemPrices.tsx +0 -0
  118. package/src/{molecules → components/molecules}/CartItem/CartItemSummary.tsx +0 -0
  119. package/src/{molecules → components/molecules}/CartItem/CartItemTitle.tsx +0 -0
  120. package/src/{molecules → components/molecules}/CartItem/index.tsx +0 -0
  121. package/src/{molecules → components/molecules}/CartItem/stories/CartItem.mdx +0 -0
  122. package/src/{molecules → components/molecules}/CartItem/stories/CartItem.stories.tsx +1 -1
  123. package/src/components/molecules/CheckboxField/CheckboxField.stories.mdx +38 -0
  124. package/src/components/molecules/CheckboxField/styles.scss +12 -0
  125. package/src/{molecules → components/molecules}/Dropdown/Dropdown.tsx +0 -0
  126. package/src/{molecules → components/molecules}/Dropdown/DropdownButton.tsx +0 -0
  127. package/src/{molecules → components/molecules}/Dropdown/DropdownItem.tsx +0 -0
  128. package/src/{molecules → components/molecules}/Dropdown/DropdownMenu.tsx +0 -0
  129. package/src/{molecules → components/molecules}/Dropdown/contexts/DropdownContext.ts +0 -0
  130. package/src/{molecules → components/molecules}/Dropdown/hooks/useDropdown.ts +0 -0
  131. package/src/{molecules → components/molecules}/Dropdown/hooks/useDropdownPosition.ts +0 -0
  132. package/src/{molecules → components/molecules}/Dropdown/index.ts +0 -0
  133. package/src/{molecules → components/molecules}/Dropdown/stories/Dropdown.mdx +0 -0
  134. package/src/{molecules → components/molecules}/Dropdown/stories/Dropdown.stories.tsx +1 -1
  135. package/src/{molecules → components/molecules}/Dropdown/stories/assets/Caret.tsx +0 -0
  136. package/src/{molecules → components/molecules}/Form/Form.tsx +0 -0
  137. package/src/{molecules → components/molecules}/Form/index.ts +0 -0
  138. package/src/{molecules → components/molecules}/Form/stories/Form.mdx +0 -0
  139. package/src/{molecules → components/molecules}/Form/stories/Form.stories.tsx +2 -1
  140. package/src/{molecules → components/molecules}/Gift/Gift.tsx +2 -3
  141. package/src/{molecules → components/molecules}/Gift/GiftContent.tsx +0 -0
  142. package/src/{molecules → components/molecules}/Gift/GiftImage.tsx +0 -0
  143. package/src/{molecules → components/molecules}/Gift/index.tsx +0 -0
  144. package/src/{molecules → components/molecules}/Gift/stories/Gift.mdx +0 -0
  145. package/src/{molecules → components/molecules}/Gift/stories/Gift.stories.tsx +1 -1
  146. package/src/components/molecules/IconButton/IconButton.stories.mdx +47 -0
  147. package/src/{molecules → components/molecules}/LoadingButton/LoadingButton.tsx +3 -8
  148. package/src/{molecules → components/molecules}/LoadingButton/index.tsx +0 -0
  149. package/src/{molecules → components/molecules}/LoadingButton/stories/LoadingButton.mdx +0 -0
  150. package/src/{molecules → components/molecules}/LoadingButton/stories/LoadingButton.stories.tsx +1 -1
  151. package/src/{molecules → components/molecules}/Modal/Modal.tsx +0 -0
  152. package/src/{molecules → components/molecules}/Modal/ModalContent.tsx +0 -0
  153. package/src/{molecules → components/molecules}/Modal/index.tsx +0 -0
  154. package/src/{molecules → components/molecules}/Modal/stories/Modal.mdx +0 -0
  155. package/src/{molecules → components/molecules}/Modal/stories/Modal.stories.tsx +1 -1
  156. package/src/{molecules → components/molecules}/Modal/useTrapFocus.ts +0 -0
  157. package/src/{molecules → components/molecules}/OrderSummary/OrderSummary.tsx +0 -0
  158. package/src/{molecules → components/molecules}/OrderSummary/index.tsx +0 -0
  159. package/src/{molecules → components/molecules}/OrderSummary/stories/OrderSummary.mdx +0 -0
  160. package/src/{molecules → components/molecules}/OrderSummary/stories/OrderSummary.stories.tsx +0 -0
  161. package/src/{molecules → components/molecules}/PaymentMethods/PaymentMethods.tsx +0 -0
  162. package/src/{molecules → components/molecules}/PaymentMethods/index.tsx +0 -0
  163. package/src/{molecules → components/molecules}/PaymentMethods/stories/PaymentMethods.mdx +0 -0
  164. package/src/{molecules → components/molecules}/PaymentMethods/stories/PaymentMethods.stories.tsx +0 -0
  165. package/src/{molecules → components/molecules}/PaymentMethods/stories/assets/Icons.tsx +0 -0
  166. package/src/{molecules → components/molecules}/PriceRange/PriceRange.tsx +0 -0
  167. package/src/{molecules → components/molecules}/PriceRange/index.ts +0 -0
  168. package/src/{molecules → components/molecules}/PriceRange/stories/PriceRange.mdx +0 -0
  169. package/src/{molecules → components/molecules}/PriceRange/stories/PriceRange.stories.tsx +1 -1
  170. package/src/{molecules → components/molecules}/ProductCard/ProductCard.tsx +0 -0
  171. package/src/{molecules → components/molecules}/ProductCard/ProductCardActions.tsx +0 -0
  172. package/src/{molecules → components/molecules}/ProductCard/ProductCardContent.tsx +0 -0
  173. package/src/{molecules → components/molecules}/ProductCard/ProductCardImage.tsx +0 -0
  174. package/src/{molecules → components/molecules}/ProductCard/index.tsx +0 -0
  175. package/src/{molecules → components/molecules}/ProductCard/stories/ProductCard.mdx +0 -0
  176. package/src/{molecules → components/molecules}/ProductCard/stories/ProductCard.stories.tsx +1 -2
  177. package/src/{molecules → components/molecules}/ProductTitle/ProductTitle.tsx +0 -0
  178. package/src/{molecules → components/molecules}/ProductTitle/index.tsx +0 -0
  179. package/src/{molecules → components/molecules}/ProductTitle/stories/ProductTitle.mdx +0 -0
  180. package/src/{molecules → components/molecules}/ProductTitle/stories/ProductTitle.stories.tsx +3 -3
  181. package/src/{molecules → components/molecules}/QuantitySelector/QuantitySelector.tsx +2 -2
  182. package/src/{molecules → components/molecules}/QuantitySelector/index.ts +0 -0
  183. package/src/{molecules → components/molecules}/QuantitySelector/stories/QuantitySelector.mdx +0 -0
  184. package/src/{molecules → components/molecules}/QuantitySelector/stories/QuantitySelector.stories.tsx +0 -0
  185. package/src/{molecules → components/molecules}/QuantitySelector/stories/assets/Icons.tsx +0 -0
  186. package/src/components/molecules/RadioField/RadioField.stories.mdx +38 -0
  187. package/src/components/molecules/RadioField/styles.scss +12 -0
  188. package/src/{molecules → components/molecules}/RadioGroup/RadioGroup.tsx +0 -0
  189. package/src/{molecules → components/molecules}/RadioGroup/RadioOption.tsx +1 -1
  190. package/src/{molecules → components/molecules}/RadioGroup/index.tsx +0 -0
  191. package/src/{molecules → components/molecules}/RadioGroup/stories/RadioGroup.mdx +0 -0
  192. package/src/{molecules → components/molecules}/RadioGroup/stories/RadioGroup.stories.tsx +0 -0
  193. package/src/{molecules → components/molecules}/RadioGroup/useRadioGroup.ts +0 -0
  194. package/src/{molecules → components/molecules}/SearchInput/SearchInput.tsx +2 -3
  195. package/src/{molecules → components/molecules}/SearchInput/index.ts +0 -0
  196. package/src/{molecules → components/molecules}/SearchInput/stories/SearchInput.mdx +0 -0
  197. package/src/{molecules → components/molecules}/SearchInput/stories/SearchInput.stories.tsx +1 -1
  198. package/src/{molecules → components/molecules}/SearchInput/stories/assets/CustomIcon.tsx +0 -0
  199. package/src/{molecules → components/molecules}/SkuSelector/SkuSelector.tsx +3 -2
  200. package/src/{molecules → components/molecules}/SkuSelector/index.tsx +0 -0
  201. package/src/{molecules → components/molecules}/SkuSelector/stories/SkuSelector.mdx +0 -0
  202. package/src/{molecules → components/molecules}/SkuSelector/stories/SkuSelector.stories.tsx +1 -1
  203. package/src/{molecules → components/molecules}/Table/Table.tsx +0 -0
  204. package/src/{molecules → components/molecules}/Table/TableBody.tsx +0 -0
  205. package/src/{molecules → components/molecules}/Table/TableCell.tsx +0 -0
  206. package/src/{molecules → components/molecules}/Table/TableFooter.tsx +0 -0
  207. package/src/{molecules → components/molecules}/Table/TableHead.tsx +0 -0
  208. package/src/{molecules → components/molecules}/Table/TableRow.tsx +0 -0
  209. package/src/{molecules → components/molecules}/Table/index.ts +0 -0
  210. package/src/{molecules → components/molecules}/Table/stories/Table.mdx +0 -0
  211. package/src/{molecules → components/molecules}/Table/stories/Table.stories.tsx +0 -0
  212. package/src/components/molecules/Tag/Tag.stories.mdx +31 -0
  213. package/src/components/molecules/Tag/styles.scss +99 -0
  214. package/src/{organisms → components/organisms}/Hero/Hero.tsx +0 -0
  215. package/src/{organisms → components/organisms}/Hero/HeroHeading.tsx +0 -0
  216. package/src/{organisms → components/organisms}/Hero/HeroImage.tsx +0 -0
  217. package/src/{organisms → components/organisms}/Hero/index.tsx +0 -0
  218. package/src/{organisms → components/organisms}/Hero/stories/Hero.mdx +0 -0
  219. package/src/{organisms → components/organisms}/Hero/stories/Hero.stories.tsx +1 -1
  220. package/src/{organisms → components/organisms}/OutOfStock/OutOfStock.tsx +0 -0
  221. package/src/{organisms → components/organisms}/OutOfStock/OutOfStockMessage.tsx +0 -0
  222. package/src/{organisms → components/organisms}/OutOfStock/OutOfStockTitle.tsx +0 -0
  223. package/src/{organisms → components/organisms}/OutOfStock/index.tsx +0 -0
  224. package/src/{organisms → components/organisms}/OutOfStock/stories/OutOfStock.mdx +0 -0
  225. package/src/{organisms → components/organisms}/OutOfStock/stories/OutOfStock.stories.tsx +1 -1
  226. package/src/{organisms → components/organisms}/Tiles/Tile.tsx +0 -0
  227. package/src/{organisms → components/organisms}/Tiles/Tiles.tsx +0 -0
  228. package/src/{organisms → components/organisms}/Tiles/index.ts +0 -0
  229. package/src/{organisms → components/organisms}/Tiles/stories/Tiles.mdx +0 -0
  230. package/src/{organisms → components/organisms}/Tiles/stories/Tiles.stories.tsx +0 -0
  231. package/src/index.ts +97 -99
  232. package/src/styles/base.scss +3 -0
  233. package/src/styles/components.scss +10 -0
  234. package/src/styles/global.scss +4 -0
  235. package/src/styles/reset.scss +54 -0
  236. package/src/styles/utilities.scss +75 -0
  237. package/src/typings/utils.d.ts +2 -2
  238. package/dist/assets/index.d.ts +0 -2
  239. package/dist/assets/index.js +0 -3
  240. package/dist/assets/index.js.map +0 -1
  241. package/src/atoms/Badge/Badge.test.tsx +0 -23
  242. package/src/atoms/Badge/Badge.tsx +0 -23
  243. package/src/atoms/Badge/index.ts +0 -2
  244. package/src/atoms/Badge/stories/Badge.mdx +0 -18
  245. package/src/atoms/Badge/stories/Badge.stories.tsx +0 -37
  246. package/src/atoms/Button/Button.test.tsx +0 -12
  247. package/src/atoms/Button/Button.tsx +0 -23
  248. package/src/atoms/Button/index.ts +0 -2
  249. package/src/atoms/Button/stories/Button.mdx +0 -18
  250. package/src/atoms/Button/stories/Button.stories.tsx +0 -36
  251. package/src/atoms/Checkbox/Checkbox.test.tsx +0 -65
  252. package/src/atoms/Checkbox/Checkbox.tsx +0 -27
  253. package/src/atoms/Checkbox/index.ts +0 -2
  254. package/src/atoms/Checkbox/stories/Checkbox.mdx +0 -18
  255. package/src/atoms/Checkbox/stories/Checkbox.stories.tsx +0 -65
  256. package/src/atoms/Icon/Icon.test.tsx +0 -43
  257. package/src/atoms/Icon/Icon.tsx +0 -26
  258. package/src/atoms/Icon/index.ts +0 -2
  259. package/src/atoms/Icon/stories/Icon.mdx +0 -18
  260. package/src/atoms/Icon/stories/Icon.stories.tsx +0 -40
  261. package/src/atoms/Icon/stories/assets/ShoppingCart.tsx +0 -23
  262. package/src/atoms/Incentive/Incentive.test.tsx +0 -36
  263. package/src/atoms/Input/Input.test.tsx +0 -73
  264. package/src/atoms/Label/Label.test.tsx +0 -71
  265. package/src/atoms/Label/Label.tsx +0 -22
  266. package/src/atoms/Label/index.ts +0 -2
  267. package/src/atoms/Label/stories/Label.mdx +0 -18
  268. package/src/atoms/Label/stories/Label.stories.tsx +0 -30
  269. package/src/atoms/Link/Link.test.tsx +0 -53
  270. package/src/atoms/List/List.test.tsx +0 -195
  271. package/src/atoms/Overlay/Overlay.test.tsx +0 -23
  272. package/src/atoms/Popover/Popover.test.tsx +0 -39
  273. package/src/atoms/Price/Price.test.tsx +0 -63
  274. package/src/atoms/Radio/Radio.test.tsx +0 -59
  275. package/src/atoms/Radio/Radio.tsx +0 -24
  276. package/src/atoms/Radio/index.ts +0 -2
  277. package/src/atoms/Radio/stories/Radio.mdx +0 -18
  278. package/src/atoms/Radio/stories/Radio.stories.tsx +0 -41
  279. package/src/atoms/Select/Select.test.tsx +0 -71
  280. package/src/atoms/Skeleton/Skeleton.test.tsx +0 -13
  281. package/src/atoms/Slider/Slider.test.tsx +0 -32
  282. package/src/atoms/Spinner/Spinner.test.tsx +0 -12
  283. package/src/atoms/TextArea/TextArea.test.tsx +0 -77
  284. package/src/hooks/useSlider/useSlider.test.ts +0 -176
  285. package/src/molecules/Accordion/Accordion.test.tsx +0 -226
  286. package/src/molecules/AggregateRating/AggregateRating.test.tsx +0 -87
  287. package/src/molecules/Alert/Alert.test.tsx +0 -23
  288. package/src/molecules/Banner/Banner.test.tsx +0 -67
  289. package/src/molecules/Breadcrumb/Breadcrumb.test.tsx +0 -124
  290. package/src/molecules/Bullets/Bullets.test.tsx +0 -128
  291. package/src/molecules/Card/Card.test.tsx +0 -68
  292. package/src/molecules/Carousel/Carousel.test.tsx +0 -587
  293. package/src/molecules/Carousel/hooks/hooks.test.ts +0 -109
  294. package/src/molecules/CartItem/CartItem.test.tsx +0 -79
  295. package/src/molecules/Dropdown/Dropdown.test.tsx +0 -275
  296. package/src/molecules/Form/Form.test.tsx +0 -61
  297. package/src/molecules/Gift/Gift.test.tsx +0 -53
  298. package/src/molecules/IconButton/IconButton.test.tsx +0 -31
  299. package/src/molecules/IconButton/IconButton.tsx +0 -35
  300. package/src/molecules/IconButton/index.tsx +0 -2
  301. package/src/molecules/IconButton/stories/IconButton.mdx +0 -27
  302. package/src/molecules/IconButton/stories/IconButton.stories.tsx +0 -35
  303. package/src/molecules/LoadingButton/LoadingButton.test.tsx +0 -14
  304. package/src/molecules/Modal/Modal.test.tsx +0 -241
  305. package/src/molecules/OrderSummary/OrderSummary.test.tsx +0 -103
  306. package/src/molecules/PaymentMethods/PaymentMethods.test.tsx +0 -37
  307. package/src/molecules/PriceRange/PriceRange.test.tsx +0 -70
  308. package/src/molecules/ProductCard/ProductCard.test.tsx +0 -75
  309. package/src/molecules/QuantitySelector/QuantitySelector.test.tsx +0 -93
  310. package/src/molecules/RadioGroup/RadioGroup.test.tsx +0 -107
  311. package/src/molecules/SearchInput/SearchInput.test.tsx +0 -34
  312. package/src/molecules/SkuSelector/SkuSelector.test.tsx +0 -42
  313. package/src/molecules/Table/Table.test.tsx +0 -233
  314. package/src/organisms/Hero/Hero.test.tsx +0 -60
  315. package/src/organisms/OutOfStock/OutOfStock.test.tsx +0 -122
  316. package/src/setupTests.ts +0 -7
  317. package/src/utils/toHaveNoIncomplete.ts +0 -76
@@ -1,107 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { renderHook } from '@testing-library/react-hooks'
3
- import userEvent from '@testing-library/user-event'
4
- import type { ReactNode } from 'react'
5
- import React from 'react'
6
-
7
- import RadioGroup from './RadioGroup'
8
- import RadioOption from './RadioOption'
9
- import { useRadioGroup } from './useRadioGroup'
10
-
11
- describe('RadioGroup', () => {
12
- it('Should render radio group with radio option', () => {
13
- const onChange = jest.fn()
14
-
15
- const { getByTestId, getByRole } = render(
16
- <RadioGroup name="radio-group" selectedValue="radio" onChange={onChange}>
17
- <RadioOption value="radio" label="Radio 1" />
18
- </RadioGroup>
19
- )
20
-
21
- const radio = getByRole('radio', { name: 'Radio 1' })
22
-
23
- expect(radio).toBeInTheDocument()
24
- expect(getByTestId('store-radio-option')).toBeInTheDocument()
25
- })
26
- it('Should render RadioOption Children', () => {
27
- const onChange = jest.fn()
28
- const { getByRole } = render(
29
- <RadioGroup
30
- name="radio-group"
31
- selectedValue="radio-1"
32
- onChange={onChange}
33
- >
34
- <RadioOption value="radio-1" label="Radio 1">
35
- <h1>Radio Group 1</h1>
36
- </RadioOption>
37
- </RadioGroup>
38
- )
39
-
40
- expect(getByRole('heading')).toHaveTextContent('Radio Group 1')
41
- })
42
- it('Should pass name from RadioGroup to RadioOptions', () => {
43
- const onChange = jest.fn()
44
-
45
- const { container } = render(
46
- <RadioGroup
47
- name="radio-group"
48
- selectedValue="radio-1"
49
- onChange={onChange}
50
- >
51
- <RadioOption value="radio-1" label="Radio 1" />
52
- <RadioOption value="radio-2" label="Radio 2" />
53
- </RadioGroup>
54
- )
55
-
56
- const options = container.querySelectorAll('[name="radio-group"]')
57
-
58
- expect(options).toHaveLength(2)
59
- })
60
-
61
- it('Should emit onChange with right value', () => {
62
- const onChange = jest.fn()
63
-
64
- const { getByTestId } = render(
65
- <RadioGroup
66
- name="radio-group"
67
- selectedValue="radio-1"
68
- onChange={onChange}
69
- >
70
- <RadioOption value="radio-1" label="Radio 1">
71
- Radio 1
72
- </RadioOption>
73
- <RadioOption
74
- value="radio-2"
75
- label="Radio 2"
76
- testId="store-radio2-option"
77
- >
78
- Radio 2
79
- </RadioOption>
80
- </RadioGroup>
81
- )
82
-
83
- const radio2 = getByTestId('store-radio2-option')
84
-
85
- userEvent.click(radio2)
86
-
87
- const [[event]] = onChange.mock.calls
88
-
89
- expect(onChange).toHaveBeenCalledTimes(1)
90
- expect(event.target.value).toEqual('radio-2')
91
- })
92
-
93
- it('Should render useRadioGroup hook', () => {
94
- const WrapperRadioGroup = ({ children }: { children: ReactNode }) => (
95
- <RadioGroup name="radio-group" selectedValue="radio-1">
96
- {children}
97
- </RadioGroup>
98
- )
99
-
100
- const { result } = renderHook(() => useRadioGroup(), {
101
- wrapper: WrapperRadioGroup,
102
- })
103
-
104
- expect(result.current.name).toEqual('radio-group')
105
- expect(result.current.selectedValue).toEqual('radio-1')
106
- })
107
- })
@@ -1,34 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { axe } from 'jest-axe'
3
- import React from 'react'
4
-
5
- import type { SearchInputProps } from './SearchInput'
6
- import SearchInput from './SearchInput'
7
-
8
- const Wrapper = (props: Partial<SearchInputProps>) => (
9
- <SearchInput testId="search-input" onSubmit={(value) => value} {...props} />
10
- )
11
-
12
- describe('SearchInput', () => {
13
- it('`data-fs-search-input-form` is present', () => {
14
- const { getByTestId } = render(<Wrapper />)
15
-
16
- expect(getByTestId('search-input')).toHaveAttribute(
17
- 'data-fs-search-input-form'
18
- )
19
- })
20
-
21
- it('`data-fs-search-input` is present and applied to `Input`', () => {
22
- const { getByTestId } = render(<Wrapper data-fs-search-input />)
23
-
24
- expect(getByTestId('store-input')).toHaveAttribute('data-fs-search-input')
25
- })
26
-
27
- describe('Accessibility', () => {
28
- it('should have no violations', async () => {
29
- const { getByTestId } = render(<Wrapper />)
30
-
31
- expect(await axe(getByTestId('search-input'))).toHaveNoViolations()
32
- })
33
- })
34
- })
@@ -1,42 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { axe } from 'jest-axe'
3
- import React from 'react'
4
-
5
- import SkuSelector from './SkuSelector'
6
-
7
- const SkuSelectorTest = () => {
8
- const options = [
9
- { label: 'Option round', value: 'Round' },
10
- { label: 'Option square', value: 'Square' },
11
- ]
12
-
13
- return <SkuSelector variant="label" options={options} activeValue="Square" />
14
- }
15
-
16
- describe('SkuSelector', () => {
17
- describe('Data attributes', () => {
18
- it('should have `data-fs-sku-selector` attribute', () => {
19
- const { getByTestId } = render(<SkuSelectorTest />)
20
-
21
- expect(getByTestId('store-sku-selector')).toHaveAttribute(
22
- 'data-fs-sku-selector'
23
- )
24
- })
25
-
26
- it('should have `data-fs-sku-selector-variant` attribute', () => {
27
- const { getByTestId } = render(<SkuSelectorTest />)
28
-
29
- expect(getByTestId('store-sku-selector')).toHaveAttribute(
30
- 'data-fs-sku-selector-variant'
31
- )
32
- })
33
- })
34
-
35
- describe('Accessibility', () => {
36
- it('should have no violations', async () => {
37
- const { getByTestId } = render(<SkuSelectorTest />)
38
-
39
- expect(await axe(getByTestId('store-sku-selector'))).toHaveNoViolations()
40
- })
41
- })
42
- })
@@ -1,233 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react'
3
- import { axe } from 'jest-axe'
4
-
5
- import Table from './Table'
6
- import TableHead from './TableHead'
7
- import TableRow from './TableRow'
8
- import TableBody from './TableBody'
9
- import TableCell from './TableCell'
10
- import TableFooter from './TableFooter'
11
-
12
- describe('Table', () => {
13
- describe('Data attributes', () => {
14
- it('should render a simple table with all expected data-attributes', () => {
15
- const { getByTestId, queryAllByTestId } = render(
16
- <Table>
17
- <TableHead>
18
- <TableRow>
19
- <TableCell variant="header">Name</TableCell>
20
- <TableCell variant="header">Age</TableCell>
21
- </TableRow>
22
- </TableHead>
23
- <TableBody>
24
- <TableRow>
25
- <TableCell>John</TableCell>
26
- <TableCell>25</TableCell>
27
- </TableRow>
28
- <TableRow>
29
- <TableCell>Carter</TableCell>
30
- <TableCell>25</TableCell>
31
- </TableRow>
32
- </TableBody>
33
- <TableFooter>
34
- <TableRow>
35
- <TableCell>Name</TableCell>
36
- <TableCell>Age</TableCell>
37
- </TableRow>
38
- </TableFooter>
39
- </Table>
40
- )
41
-
42
- const table = getByTestId('store-table')
43
-
44
- expect(table).toHaveAttribute('data-fs-table')
45
-
46
- const tableHead = getByTestId('store-table-head')
47
-
48
- expect(tableHead).toHaveAttribute('data-table-head')
49
-
50
- const tableBody = getByTestId('store-table-body')
51
-
52
- expect(tableBody).toHaveAttribute('data-table-body')
53
-
54
- const tableFooter = getByTestId('store-table-footer')
55
-
56
- expect(tableFooter).toHaveAttribute('data-table-footer')
57
-
58
- const tableRows = queryAllByTestId('store-table-row')
59
-
60
- expect(tableRows).toHaveLength(4)
61
- tableRows.forEach((row) => {
62
- expect(row).toHaveAttribute('data-table-row')
63
- })
64
-
65
- const tableCells = queryAllByTestId('store-table-cell')
66
-
67
- // Make sure 8 cells were rendered and all contain the
68
- // data-table-cell attribute.
69
- expect(tableCells).toHaveLength(8)
70
- tableCells.forEach((row) => {
71
- expect(row).toHaveAttribute('data-table-cell')
72
- })
73
-
74
- // Make sure that 2 header cells and 6 data cells were rendered, with their
75
- // corresponding attributes.
76
- expect(table.querySelectorAll('[data-table-cell=header]')).toHaveLength(2)
77
- expect(table.querySelectorAll('[data-table-cell=data]')).toHaveLength(6)
78
- })
79
- })
80
-
81
- // WAI-ARIA tests
82
- // https://www.w3.org/WAI/tutorials/tables/
83
- describe('Table WAI-ARIA Specifications', () => {
84
- describe('Tables with one header', () => {
85
- it('should have no violations on a table with header cells in the top row only', async () => {
86
- const { container } = render(
87
- <Table>
88
- <TableHead>
89
- <TableRow>
90
- <TableCell variant="header">Name</TableCell>
91
- <TableCell variant="header">Age</TableCell>
92
- </TableRow>
93
- </TableHead>
94
- <TableBody>
95
- <TableRow>
96
- <TableCell>John</TableCell>
97
- <TableCell>25</TableCell>
98
- </TableRow>
99
- <TableRow>
100
- <TableCell>Carter</TableCell>
101
- <TableCell>25</TableCell>
102
- </TableRow>
103
- </TableBody>
104
- </Table>
105
- )
106
-
107
- expect(await axe(container)).toHaveNoViolations()
108
- })
109
-
110
- it('should have no violations on a table with header cells in the first column only', async () => {
111
- const { container } = render(
112
- <Table>
113
- <TableBody>
114
- <TableRow>
115
- <TableCell variant="header">Date</TableCell>
116
- <TableCell>12 February</TableCell>
117
- <TableCell>24 March</TableCell>
118
- <TableCell>14 April</TableCell>
119
- </TableRow>
120
- <TableRow>
121
- <TableCell variant="header">Event</TableCell>
122
- <TableCell>Waltz with Strauss</TableCell>
123
- <TableCell>The Obelisks</TableCell>
124
- <TableCell>The What</TableCell>
125
- </TableRow>
126
- <TableRow>
127
- <TableCell variant="header">Venue</TableCell>
128
- <TableCell>Main Hall</TableCell>
129
- <TableCell>West Wing</TableCell>
130
- <TableCell>Main Hall</TableCell>
131
- </TableRow>
132
- </TableBody>
133
- </Table>
134
- )
135
-
136
- expect(await axe(container)).toHaveNoViolations()
137
- })
138
-
139
- // https://www.w3.org/WAI/WCAG21/Techniques/html/H63
140
- it('should have no violations on a table with ambiguous data, where scope should be used', async () => {
141
- const { container } = render(
142
- <Table>
143
- <TableHead>
144
- <TableRow>
145
- <TableCell variant="header" scope="col">
146
- Last Name
147
- </TableCell>
148
- <TableCell variant="header" scope="col">
149
- First Name
150
- </TableCell>
151
- <TableCell variant="header" scope="col">
152
- City
153
- </TableCell>
154
- </TableRow>
155
- </TableHead>
156
- <TableBody>
157
- <TableRow>
158
- <TableCell>Phoenix</TableCell>
159
- <TableCell>Imari</TableCell>
160
- <TableCell>Henry</TableCell>
161
- </TableRow>
162
- <TableRow>
163
- <TableCell>Zeki</TableCell>
164
- <TableCell>Rome</TableCell>
165
- <TableCell>Min</TableCell>
166
- </TableRow>
167
- <TableRow>
168
- <TableCell>Apirka</TableCell>
169
- <TableCell>Kelly</TableCell>
170
- <TableCell>Brynn</TableCell>
171
- </TableRow>
172
- </TableBody>
173
- </Table>
174
- )
175
-
176
- expect(await axe(container)).toHaveNoViolations()
177
- })
178
- })
179
-
180
- describe('Tables with two headers', () => {
181
- it('should have no violations on a table with header cells in the top row and first column', async () => {
182
- const { container } = render(
183
- <Table>
184
- <TableHead>
185
- <TableRow>
186
- <TableCell />
187
- <TableCell variant="header" scope="col">
188
- Monday
189
- </TableCell>
190
- <TableCell variant="header" scope="col">
191
- Tuesday
192
- </TableCell>
193
- <TableCell variant="header" scope="col">
194
- Wednesday
195
- </TableCell>
196
- <TableCell variant="header" scope="col">
197
- Thursday
198
- </TableCell>
199
- <TableCell variant="header" scope="col">
200
- Friday
201
- </TableCell>
202
- </TableRow>
203
- </TableHead>
204
- <TableBody>
205
- <TableRow>
206
- <TableCell variant="header" scope="row">
207
- 09:00 - 11:00
208
- </TableCell>
209
- <TableCell>Closed</TableCell>
210
- <TableCell>Open</TableCell>
211
- <TableCell>Open</TableCell>
212
- <TableCell>Closed</TableCell>
213
- <TableCell>Closed</TableCell>
214
- </TableRow>
215
- <TableRow>
216
- <TableCell variant="header" scope="row">
217
- 11:00 - 13:00
218
- </TableCell>
219
- <TableCell>Open</TableCell>
220
- <TableCell>Open</TableCell>
221
- <TableCell>Closed</TableCell>
222
- <TableCell>Closed</TableCell>
223
- <TableCell>Closed</TableCell>
224
- </TableRow>
225
- </TableBody>
226
- </Table>
227
- )
228
-
229
- expect(await axe(container)).toHaveNoViolations()
230
- })
231
- })
232
- })
233
- })
@@ -1,60 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { axe } from 'jest-axe'
3
- import React from 'react'
4
-
5
- import Hero from './Hero'
6
- import HeroImage from './HeroImage'
7
- import HeroHeading from './HeroHeading'
8
-
9
- const HeroTest = () => {
10
- return (
11
- <Hero data-custom-attribute>
12
- <HeroImage>
13
- <img
14
- alt="Quest 2 Controller on a table"
15
- src="https://storeframework.vtexassets.com/arquivos/ids/190897/Photo.jpg"
16
- />
17
- </HeroImage>
18
- <HeroHeading>
19
- <h3>Get yo know our next release</h3>
20
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
21
- <a href="/">Shop Now</a>
22
- </HeroHeading>
23
- </Hero>
24
- )
25
- }
26
-
27
- describe('Hero', () => {
28
- describe('Data attributes', () => {
29
- const { getByTestId } = render(<HeroTest />)
30
-
31
- const hero = getByTestId('store-hero')
32
- const heroImage = getByTestId('store-hero-image')
33
- const heroHeading = getByTestId('store-hero-heading')
34
-
35
- it('`Hero` component should have `data-fs-hero` attribute', () => {
36
- expect(hero).toHaveAttribute('data-fs-hero')
37
- })
38
-
39
- it('`Hero` component should have custom data attribute `data-custom-attribute`', () => {
40
- expect(hero).toHaveAttribute('data-custom-attribute')
41
- })
42
-
43
- it('`HeroImage` component should have `data-hero-image` attribute', () => {
44
- expect(heroImage).toHaveAttribute('data-hero-image')
45
- })
46
-
47
- it('`HeroHeading` component should have `data-hero-heading` attribute', () => {
48
- expect(heroHeading).toHaveAttribute('data-hero-heading')
49
- })
50
- })
51
-
52
- describe('Accessibility', () => {
53
- it('should have no violations', async () => {
54
- const { getByTestId } = render(<HeroTest />)
55
-
56
- expect(await axe(getByTestId('store-hero'))).toHaveNoViolations()
57
- expect(await axe(getByTestId('store-hero'))).toHaveNoIncompletes()
58
- })
59
- })
60
- })
@@ -1,122 +0,0 @@
1
- import { render, screen } from '@testing-library/react'
2
- import userEvent from '@testing-library/user-event'
3
- import { axe } from 'jest-axe'
4
- import React from 'react'
5
-
6
- import { OutOfStockMessage, OutOfStockTitle } from '.'
7
- import Button from '../../atoms/Button'
8
- import Input from '../../atoms/Input'
9
- import Label from '../../atoms/Label'
10
- import OutOfStock from './OutOfStock'
11
-
12
- const SimpleOutOfStock = () => (
13
- <OutOfStock>
14
- <OutOfStockTitle>
15
- Text <span>icon</span>
16
- </OutOfStockTitle>
17
- <OutOfStockMessage>Notify me when available</OutOfStockMessage>
18
- <Label>
19
- Email
20
- <Input />
21
- </Label>
22
- <Button>Notify me</Button>
23
- </OutOfStock>
24
- )
25
-
26
- describe('OutOfStock', () => {
27
- it('`Out Of Stock` components should have corrects attributes', () => {
28
- render(<SimpleOutOfStock />)
29
-
30
- const outOfStock = screen.getByTestId('store-out-of-stock')
31
- const outOfStockTitle = screen.getByTestId('store-out-of-stock-title')
32
- const outOfStockMessage = screen.getByTestId('store-out-of-stock-message')
33
- const outOfStockForm = screen.getByTestId('store-out-of-stock-form')
34
-
35
- expect(outOfStock).toHaveAttribute('data-fs-out-of-stock')
36
- expect(outOfStockForm).toHaveAttribute('data-out-of-stock-form')
37
- expect(outOfStockTitle).toHaveAttribute('data-out-of-stock-title')
38
- expect(outOfStockMessage).toHaveAttribute('data-out-of-stock-message')
39
- })
40
-
41
- it('Should emit event', () => {
42
- const onSubmitMock = jest.fn((e) => e.preventDefault())
43
-
44
- render(
45
- <OutOfStock onSubmit={onSubmitMock}>
46
- <OutOfStockTitle>Out of Stock</OutOfStockTitle>
47
- <Input name="email" />
48
- <Button type="submit">Notify me</Button>
49
- </OutOfStock>
50
- )
51
-
52
- const outOfStockEventButton = screen.getByTestId('store-button')
53
-
54
- userEvent.click(outOfStockEventButton)
55
-
56
- expect(onSubmitMock).toHaveBeenCalledTimes(1)
57
- })
58
-
59
- it('Should not render message', () => {
60
- render(
61
- <OutOfStock>
62
- <OutOfStockTitle>Out of Stock</OutOfStockTitle>
63
- <Input name="email" />
64
- <Button type="submit">Notify me</Button>
65
- </OutOfStock>
66
- )
67
-
68
- const message = screen.queryByTestId('store-out-of-stock-message')
69
-
70
- expect(message).not.toBeInTheDocument()
71
- })
72
- })
73
-
74
- describe('Accessibility', () => {
75
- it('should not have violations or incompletes', async () => {
76
- const { container } = render(<SimpleOutOfStock />)
77
-
78
- expect(await axe(container)).toHaveNoViolations()
79
- expect(await axe(container)).toHaveNoIncompletes()
80
- })
81
-
82
- it('Out of Stock component should be a `section`', () => {
83
- render(<SimpleOutOfStock />)
84
- const outOfStock = screen.getByTestId('store-out-of-stock')
85
-
86
- expect(outOfStock.tagName).toEqual('SECTION')
87
- })
88
-
89
- it('Out of Stock `title` component should be a `heading 2` as default', () => {
90
- render(<SimpleOutOfStock />)
91
- const outOfStockTitle = screen.getByTestId('store-out-of-stock-title')
92
-
93
- expect(outOfStockTitle.tagName).toEqual('H2')
94
- })
95
-
96
- it('Out of Stock `message` should be a `paragraph` as default', () => {
97
- render(<SimpleOutOfStock />)
98
- const outOfStockMessage = screen.getByTestId('store-out-of-stock-message')
99
-
100
- expect(outOfStockMessage.tagName).toEqual('P')
101
- })
102
-
103
- it('Out of Stock should render `title` as heading 1 and `message` as span', () => {
104
- render(
105
- <OutOfStock>
106
- <OutOfStockTitle as="h1">Head Out Os Stock</OutOfStockTitle>
107
- <OutOfStockMessage as="span">Head Out Os Stock</OutOfStockMessage>
108
- <Label>
109
- Email
110
- <Input />
111
- </Label>
112
- <Button>Notify me</Button>
113
- </OutOfStock>
114
- )
115
-
116
- const outOfStockMessage = screen.getByTestId('store-out-of-stock-message')
117
- const outOfStockTitle = screen.getByTestId('store-out-of-stock-title')
118
-
119
- expect(outOfStockTitle.tagName).toEqual('H1')
120
- expect(outOfStockMessage.tagName).toEqual('SPAN')
121
- })
122
- })
package/src/setupTests.ts DELETED
@@ -1,7 +0,0 @@
1
- import '@testing-library/jest-dom/extend-expect'
2
- import { toHaveNoViolations } from 'jest-axe'
3
-
4
- import { toHaveNoIncompletes } from './utils/toHaveNoIncomplete'
5
-
6
- expect.extend(toHaveNoViolations)
7
- expect.extend(toHaveNoIncompletes)
@@ -1,76 +0,0 @@
1
- import type { AxeResults } from 'axe-core'
2
- import { printReceived, matcherHint } from 'jest-matcher-utils'
3
- import chalk from 'chalk'
4
-
5
- // This code is based on jest-axe library.
6
- // https://github.com/nickcolley/jest-axe
7
- export const toHaveNoIncompletes = {
8
- toHaveNoIncompletes: (results: AxeResults) => {
9
- if (typeof results.incomplete === 'undefined') {
10
- throw new Error('No incompletes found in aXe results object')
11
- }
12
-
13
- const reporter = (incompletes: AxeResults['incomplete']) => {
14
- if (incompletes.length === 0) {
15
- return []
16
- }
17
-
18
- const lineBreak = '\n\n'
19
- const horizontalLine = '\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500'
20
-
21
- return incompletes
22
- .map((incomplete) => {
23
- const errorBody = incomplete.nodes
24
- .map((node) => {
25
- const selector = node.target.join(', ')
26
- const expectedText = `Expected the HTML found at $('${selector}') to have no incompletes:${lineBreak}`
27
-
28
- return `${
29
- expectedText + chalk.grey(node.html) + lineBreak
30
- }Received:${lineBreak}${printReceived(
31
- `${incomplete.help} (${incomplete.id})`
32
- )}${lineBreak}${chalk.yellow(node.failureSummary)}${lineBreak}${
33
- incomplete.helpUrl
34
- ? `You can find more information on this issue here: \n${chalk.blue(
35
- incomplete.helpUrl
36
- )}`
37
- : ''
38
- }`
39
- })
40
- .join(lineBreak)
41
-
42
- return errorBody
43
- })
44
- .join(lineBreak + horizontalLine + lineBreak)
45
- }
46
-
47
- const { incomplete: incompletes } = results
48
- const formatedIncompletes = reporter(incompletes)
49
- const pass = formatedIncompletes.length === 0
50
-
51
- const message = () => {
52
- if (pass) {
53
- return ''
54
- }
55
-
56
- return (
57
- `${matcherHint('.toHaveNoIncompletes')}\n\n` + `${formatedIncompletes}`
58
- )
59
- }
60
-
61
- return { actual: incompletes, message, pass }
62
- },
63
- }
64
-
65
- declare global {
66
- // eslint-disable-next-line
67
- namespace jest {
68
- interface Matchers<R> {
69
- toHaveNoIncompletes(): R
70
- }
71
- }
72
-
73
- // axe-core depends on a global Node
74
- // eslint-disable-next-line
75
- interface Node {}
76
- }