@watermarkinsights/ripple 5.0.0 → 5.1.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 (244) hide show
  1. package/dist/cjs/{app-globals-d6c37251.js → app-globals-aad9863d.js} +2 -2
  2. package/dist/cjs/{chartFunctions-b32ecbeb.js → chartFunctions-e86ed63c.js} +8 -4
  3. package/dist/cjs/{index-0f1bacce.js → index-4853a7b4.js} +537 -494
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/priv-chart-popover.cjs.entry.js +1 -1
  6. package/dist/cjs/priv-datepicker.cjs.entry.js +1 -1
  7. package/dist/cjs/priv-navigator-button.cjs.entry.js +1 -1
  8. package/dist/cjs/priv-navigator-item.cjs.entry.js +1 -1
  9. package/dist/cjs/ripple.cjs.js +3 -3
  10. package/dist/cjs/wm-action-menu_2.cjs.entry.js +1 -1
  11. package/dist/cjs/wm-button.cjs.entry.js +1 -1
  12. package/dist/cjs/wm-chart-slice.cjs.entry.js +1 -1
  13. package/dist/cjs/wm-chart.cjs.entry.js +2 -2
  14. package/dist/cjs/wm-datepicker.cjs.entry.js +1 -1
  15. package/dist/cjs/wm-file-list.cjs.entry.js +1 -1
  16. package/dist/cjs/wm-file.cjs.entry.js +1 -1
  17. package/dist/cjs/wm-input.cjs.entry.js +1 -1
  18. package/dist/cjs/wm-line-chart.cjs.entry.js +2 -2
  19. package/dist/cjs/wm-modal-footer.cjs.entry.js +1 -1
  20. package/dist/cjs/wm-modal-header.cjs.entry.js +1 -1
  21. package/dist/cjs/wm-modal.cjs.entry.js +1 -1
  22. package/dist/cjs/wm-navigation_3.cjs.entry.js +1 -1
  23. package/dist/cjs/wm-navigator.cjs.entry.js +1 -1
  24. package/dist/cjs/wm-option_2.cjs.entry.js +1 -1
  25. package/dist/cjs/wm-pagination.cjs.entry.js +1 -1
  26. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +2 -2
  27. package/dist/cjs/wm-search.cjs.entry.js +1 -1
  28. package/dist/cjs/wm-snackbar.cjs.entry.js +1 -1
  29. package/dist/cjs/wm-tab-item_3.cjs.entry.js +1 -1
  30. package/dist/cjs/wm-tag-input.cjs.entry.js +1 -1
  31. package/dist/cjs/wm-tag-option.cjs.entry.js +1 -1
  32. package/dist/cjs/wm-textarea.cjs.entry.js +1 -1
  33. package/dist/cjs/wm-timepicker.cjs.entry.js +1 -1
  34. package/dist/cjs/wm-toggletip.cjs.entry.js +1 -1
  35. package/dist/cjs/wm-uploader.cjs.entry.js +1 -1
  36. package/dist/cjs/wm-wrapper.cjs.entry.js +1 -1
  37. package/dist/collection/collection-manifest.json +2 -2
  38. package/dist/collection/components/charts/chartFunctions.js +7 -3
  39. package/dist/esm/{app-globals-2df700e6.js → app-globals-4e667854.js} +2 -2
  40. package/dist/esm/{chartFunctions-e43ec877.js → chartFunctions-8098e455.js} +8 -4
  41. package/dist/esm/{index-5815b978.js → index-7923308f.js} +537 -494
  42. package/dist/esm/loader.js +3 -3
  43. package/dist/esm/priv-chart-popover.entry.js +1 -1
  44. package/dist/esm/priv-datepicker.entry.js +1 -1
  45. package/dist/esm/priv-navigator-button.entry.js +1 -1
  46. package/dist/esm/priv-navigator-item.entry.js +1 -1
  47. package/dist/esm/ripple.js +4 -4
  48. package/dist/esm/wm-action-menu_2.entry.js +1 -1
  49. package/dist/esm/wm-button.entry.js +1 -1
  50. package/dist/esm/wm-chart-slice.entry.js +1 -1
  51. package/dist/esm/wm-chart.entry.js +2 -2
  52. package/dist/esm/wm-datepicker.entry.js +1 -1
  53. package/dist/esm/wm-file-list.entry.js +1 -1
  54. package/dist/esm/wm-file.entry.js +1 -1
  55. package/dist/esm/wm-input.entry.js +1 -1
  56. package/dist/esm/wm-line-chart.entry.js +2 -2
  57. package/dist/esm/wm-modal-footer.entry.js +1 -1
  58. package/dist/esm/wm-modal-header.entry.js +1 -1
  59. package/dist/esm/wm-modal.entry.js +1 -1
  60. package/dist/esm/wm-navigation_3.entry.js +1 -1
  61. package/dist/esm/wm-navigator.entry.js +1 -1
  62. package/dist/esm/wm-option_2.entry.js +1 -1
  63. package/dist/esm/wm-pagination.entry.js +1 -1
  64. package/dist/esm/wm-progress-indicator_3.entry.js +2 -2
  65. package/dist/esm/wm-search.entry.js +1 -1
  66. package/dist/esm/wm-snackbar.entry.js +1 -1
  67. package/dist/esm/wm-tab-item_3.entry.js +1 -1
  68. package/dist/esm/wm-tag-input.entry.js +1 -1
  69. package/dist/esm/wm-tag-option.entry.js +1 -1
  70. package/dist/esm/wm-textarea.entry.js +1 -1
  71. package/dist/esm/wm-timepicker.entry.js +1 -1
  72. package/dist/esm/wm-toggletip.entry.js +1 -1
  73. package/dist/esm/wm-uploader.entry.js +1 -1
  74. package/dist/esm/wm-wrapper.entry.js +1 -1
  75. package/dist/esm-es5/{app-globals-2df700e6.js → app-globals-4e667854.js} +1 -1
  76. package/dist/esm-es5/chartFunctions-8098e455.js +1 -0
  77. package/dist/esm-es5/index-7923308f.js +1 -0
  78. package/dist/esm-es5/loader.js +1 -1
  79. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  80. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  81. package/dist/esm-es5/priv-navigator-button.entry.js +1 -1
  82. package/dist/esm-es5/priv-navigator-item.entry.js +1 -1
  83. package/dist/esm-es5/ripple.js +1 -1
  84. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  85. package/dist/esm-es5/wm-button.entry.js +1 -1
  86. package/dist/esm-es5/wm-chart-slice.entry.js +1 -1
  87. package/dist/esm-es5/wm-chart.entry.js +1 -1
  88. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  89. package/dist/esm-es5/wm-file-list.entry.js +1 -1
  90. package/dist/esm-es5/wm-file.entry.js +1 -1
  91. package/dist/esm-es5/wm-input.entry.js +1 -1
  92. package/dist/esm-es5/wm-line-chart.entry.js +1 -1
  93. package/dist/esm-es5/wm-modal-footer.entry.js +1 -1
  94. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  95. package/dist/esm-es5/wm-modal.entry.js +1 -1
  96. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  97. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  98. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  99. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  100. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  101. package/dist/esm-es5/wm-search.entry.js +1 -1
  102. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  103. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  104. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  105. package/dist/esm-es5/wm-tag-option.entry.js +1 -1
  106. package/dist/esm-es5/wm-textarea.entry.js +1 -1
  107. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  108. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  109. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  110. package/dist/esm-es5/wm-wrapper.entry.js +1 -1
  111. package/dist/loader/index.d.ts +3 -0
  112. package/dist/ripple/{p-df4ab5de.system.entry.js → p-00f8637e.system.entry.js} +1 -1
  113. package/dist/ripple/{p-0a05e6d7.system.entry.js → p-06c018cf.system.entry.js} +1 -1
  114. package/dist/ripple/{p-411f0d1d.entry.js → p-0707b4c2.entry.js} +1 -1
  115. package/dist/ripple/{p-e14c3721.entry.js → p-0bb464b1.entry.js} +1 -1
  116. package/dist/ripple/{p-6f47d86c.system.entry.js → p-0d0e0a1e.system.entry.js} +1 -1
  117. package/dist/ripple/{p-9b894527.entry.js → p-0e7025db.entry.js} +1 -1
  118. package/dist/ripple/{p-d65e9846.entry.js → p-0ec1e075.entry.js} +1 -1
  119. package/dist/ripple/{p-9a977fbd.entry.js → p-0f72ed3a.entry.js} +1 -1
  120. package/dist/ripple/{p-b5729148.system.entry.js → p-186a4d76.system.entry.js} +1 -1
  121. package/dist/ripple/{p-9433f29c.entry.js → p-18c1593b.entry.js} +1 -1
  122. package/dist/ripple/{p-194c06e1.entry.js → p-19f29a48.entry.js} +1 -1
  123. package/dist/ripple/{p-85e59e6a.system.entry.js → p-1ee68e06.system.entry.js} +1 -1
  124. package/dist/ripple/{p-46584e7e.system.entry.js → p-1fcc8007.system.entry.js} +1 -1
  125. package/dist/ripple/{p-87eb2f99.system.entry.js → p-28119849.system.entry.js} +1 -1
  126. package/dist/ripple/{p-0c218ac2.system.entry.js → p-2849847d.system.entry.js} +1 -1
  127. package/dist/ripple/{p-70c459b2.entry.js → p-2f39732e.entry.js} +1 -1
  128. package/dist/ripple/{p-ac727a0a.system.entry.js → p-30ee0f5c.system.entry.js} +1 -1
  129. package/dist/ripple/{p-44f2e1a7.entry.js → p-340f96b5.entry.js} +1 -1
  130. package/dist/ripple/{p-74565577.system.entry.js → p-3639dbbc.system.entry.js} +1 -1
  131. package/dist/ripple/{p-1b8584f9.entry.js → p-3e605541.entry.js} +1 -1
  132. package/dist/ripple/{p-440571f7.system.entry.js → p-439d839b.system.entry.js} +1 -1
  133. package/dist/ripple/{p-e80009db.entry.js → p-445d6915.entry.js} +1 -1
  134. package/dist/ripple/{p-1435a717.entry.js → p-48ed56a0.entry.js} +1 -1
  135. package/dist/ripple/{p-4a8016fb.entry.js → p-49f94f8a.entry.js} +1 -1
  136. package/dist/ripple/{p-764cee74.system.js → p-4ba32e58.system.js} +1 -1
  137. package/dist/ripple/{p-0bf7cdda.system.entry.js → p-510fab1c.system.entry.js} +1 -1
  138. package/dist/ripple/p-539b7be9.system.js +2 -0
  139. package/dist/ripple/{p-7ffb6f07.entry.js → p-57694990.entry.js} +1 -1
  140. package/dist/ripple/{p-e9d29b5b.system.entry.js → p-58a286e8.system.entry.js} +1 -1
  141. package/dist/ripple/{p-ef0854e6.entry.js → p-5ff41948.entry.js} +1 -1
  142. package/dist/ripple/{p-76740c92.entry.js → p-636ca7f2.entry.js} +1 -1
  143. package/dist/ripple/{p-0bef5c1b.system.entry.js → p-66a57d81.system.entry.js} +1 -1
  144. package/dist/ripple/p-681c1853.js +1 -0
  145. package/dist/ripple/{p-7d2bd039.entry.js → p-6b71806b.entry.js} +1 -1
  146. package/dist/ripple/{p-5c4245d9.system.entry.js → p-7afa2fdc.system.entry.js} +1 -1
  147. package/dist/ripple/{p-ce492826.js → p-7c12ac23.js} +1 -1
  148. package/dist/ripple/{p-5297476b.entry.js → p-7cb98aa5.entry.js} +1 -1
  149. package/dist/ripple/{p-87c85aac.system.entry.js → p-7dbc4abc.system.entry.js} +1 -1
  150. package/dist/ripple/{p-6f61a5f1.entry.js → p-8c7b9bad.entry.js} +1 -1
  151. package/dist/ripple/p-94a54d68.system.js +1 -0
  152. package/dist/ripple/{p-b878d9c7.entry.js → p-950edf62.entry.js} +1 -1
  153. package/dist/ripple/{p-6a231093.system.entry.js → p-96f3d9e7.system.entry.js} +1 -1
  154. package/dist/ripple/{p-47441a2a.system.entry.js → p-9bda128e.system.entry.js} +1 -1
  155. package/dist/ripple/{p-eab22c94.entry.js → p-9ca027b7.entry.js} +1 -1
  156. package/dist/ripple/{p-6372934d.entry.js → p-9d4ea9f8.entry.js} +1 -1
  157. package/dist/ripple/{p-49632308.system.entry.js → p-9d8817a7.system.entry.js} +1 -1
  158. package/dist/ripple/{p-9936c43c.system.entry.js → p-a0098136.system.entry.js} +1 -1
  159. package/dist/ripple/p-a431d6e5.js +2 -0
  160. package/dist/ripple/{p-7ade6e66.system.entry.js → p-a6119885.system.entry.js} +1 -1
  161. package/dist/ripple/{p-25cf3ccb.entry.js → p-a77f2168.entry.js} +1 -1
  162. package/dist/ripple/{p-3cc9b812.entry.js → p-adfaeeea.entry.js} +1 -1
  163. package/dist/ripple/{p-66960670.system.entry.js → p-b02c0c41.system.entry.js} +1 -1
  164. package/dist/ripple/{p-1166513e.system.entry.js → p-bbb8c02f.system.entry.js} +1 -1
  165. package/dist/ripple/{p-3b9a9d73.entry.js → p-bd7e892d.entry.js} +1 -1
  166. package/dist/ripple/{p-441354a5.system.entry.js → p-c9552e88.system.entry.js} +1 -1
  167. package/dist/ripple/{p-018498a7.system.entry.js → p-cd0a862f.system.entry.js} +1 -1
  168. package/dist/ripple/{p-25e011a6.entry.js → p-d344e490.entry.js} +1 -1
  169. package/dist/ripple/{p-dabff389.system.entry.js → p-d87e105b.system.entry.js} +1 -1
  170. package/dist/ripple/{p-44d8f4b2.system.entry.js → p-e0ff556b.system.entry.js} +1 -1
  171. package/dist/ripple/{p-8edd4ce6.system.entry.js → p-e19e1ece.system.entry.js} +1 -1
  172. package/dist/ripple/{p-c53f1dcb.entry.js → p-e3d8f2f6.entry.js} +1 -1
  173. package/dist/ripple/{p-116477b7.entry.js → p-e8eef357.entry.js} +1 -1
  174. package/dist/ripple/{p-e0ca71d3.entry.js → p-eb596891.entry.js} +1 -1
  175. package/dist/ripple/{p-35627044.system.entry.js → p-ec384895.system.entry.js} +1 -1
  176. package/dist/ripple/{p-5356db9b.entry.js → p-eccb5aaf.entry.js} +1 -1
  177. package/dist/ripple/{p-567c5edd.system.entry.js → p-edcb8f48.system.entry.js} +1 -1
  178. package/dist/ripple/{p-d8f1fd76.entry.js → p-f963be6d.entry.js} +1 -1
  179. package/dist/ripple/{p-838d75c2.system.js → p-fde81b94.system.js} +1 -1
  180. package/dist/ripple/{p-d37a720b.system.entry.js → p-ff7dac66.system.entry.js} +1 -1
  181. package/dist/ripple/ripple.esm.js +1 -1
  182. package/dist/ripple/ripple.js +1 -1
  183. package/dist/types/stencil-public-runtime.d.ts +0 -2
  184. package/package.json +2 -2
  185. package/dist/collection/components/charts/chartFunctions.spec.js +0 -16
  186. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.e2e.js +0 -81
  187. package/dist/collection/components/charts/screenshots.e2e.js +0 -96
  188. package/dist/collection/components/charts/wm-chart/wm-chart.e2e.js +0 -213
  189. package/dist/collection/components/charts/wm-chart/wm-chart.spec.js +0 -37
  190. package/dist/collection/components/charts/wm-line-chart/wm-line-chart.e2e.js +0 -176
  191. package/dist/collection/components/charts/wm-line-chart/wm-line-chart.spec.js +0 -163
  192. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.e2e.js +0 -69
  193. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.spec.js +0 -79
  194. package/dist/collection/components/wm-action-menu/wm-action-menu.e2e.js +0 -200
  195. package/dist/collection/components/wm-action-menu/wm-action-menu.spec.js +0 -48
  196. package/dist/collection/components/wm-button/wm-button.e2e.js +0 -55
  197. package/dist/collection/components/wm-button/wm-button.spec.js +0 -74
  198. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.spec.js +0 -76
  199. package/dist/collection/components/wm-datepicker/wm-datepicker.e2e.js +0 -382
  200. package/dist/collection/components/wm-datepicker/wm-datepicker.spec.js +0 -21
  201. package/dist/collection/components/wm-file/wm-file.spec.js +0 -194
  202. package/dist/collection/components/wm-file-list/wm-file-list.spec.js +0 -69
  203. package/dist/collection/components/wm-input/wm-input.e2e.js +0 -32
  204. package/dist/collection/components/wm-input/wm-input.spec.js +0 -173
  205. package/dist/collection/components/wm-menuitem/wm-menuitem.e2e.js +0 -23
  206. package/dist/collection/components/wm-menuitem/wm-menuitem.spec.js +0 -54
  207. package/dist/collection/components/wm-modal/wm-modal-footer.spec.js +0 -11
  208. package/dist/collection/components/wm-modal/wm-modal-header.spec.js +0 -8
  209. package/dist/collection/components/wm-modal/wm-modal.e2e.js +0 -104
  210. package/dist/collection/components/wm-modal/wm-modal.spec.js +0 -30
  211. package/dist/collection/components/wm-navigation/wm-navigation.e2e.js +0 -102
  212. package/dist/collection/components/wm-navigation/wm-navigation.spec.js +0 -91
  213. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.e2e.js +0 -50
  214. package/dist/collection/components/wm-navigator/wm-navigator.e2e.js +0 -209
  215. package/dist/collection/components/wm-navigator/wm-navigator.spec.js +0 -177
  216. package/dist/collection/components/wm-option/wm-option.e2e.js +0 -22
  217. package/dist/collection/components/wm-option/wm-option.spec.js +0 -63
  218. package/dist/collection/components/wm-pagination/wm-pagination.e2e.js +0 -312
  219. package/dist/collection/components/wm-search/wm-search.e2e.js +0 -76
  220. package/dist/collection/components/wm-search/wm-search.spec.js +0 -71
  221. package/dist/collection/components/wm-select/wm-select.e2e.js +0 -521
  222. package/dist/collection/components/wm-select/wm-select.spec.js +0 -271
  223. package/dist/collection/components/wm-snackbar/wm-snackbar.e2e.js +0 -112
  224. package/dist/collection/components/wm-snackbar/wm-snackbar.spec.js +0 -9
  225. package/dist/collection/components/wm-tabs/wm-tabs.e2e.js +0 -91
  226. package/dist/collection/components/wm-tabs/wm-tabs.spec.js +0 -12
  227. package/dist/collection/components/wm-tag-input/wm-tag-input.e2e.js +0 -204
  228. package/dist/collection/components/wm-tag-input/wm-tag-input.spec.js +0 -195
  229. package/dist/collection/components/wm-textarea/wm-textarea.e2e.js +0 -41
  230. package/dist/collection/components/wm-textarea/wm-textarea.spec.js +0 -79
  231. package/dist/collection/components/wm-timepicker/wm-timepicker.e2e.js +0 -163
  232. package/dist/collection/components/wm-timepicker/wm-timepicker.spec.js +0 -147
  233. package/dist/collection/components/wm-toggletip/wm-toggletip.e2e.js +0 -69
  234. package/dist/collection/components/wm-toggletip/wm-toggletip.spec.js +0 -21
  235. package/dist/collection/components/wm-uploader/wm-uploader.e2e.js +0 -70
  236. package/dist/collection/components/wm-uploader/wm-uploader.spec.js +0 -234
  237. package/dist/collection/global/functions.spec.js +0 -126
  238. package/dist/collection/lang/lang.spec.js +0 -20
  239. package/dist/esm-es5/chartFunctions-e43ec877.js +0 -1
  240. package/dist/esm-es5/index-5815b978.js +0 -1
  241. package/dist/ripple/p-1eb84629.system.js +0 -2
  242. package/dist/ripple/p-7bf00a52.js +0 -2
  243. package/dist/ripple/p-9bf31e42.js +0 -1
  244. package/dist/ripple/p-aa41cf09.system.js +0 -1
@@ -1,213 +0,0 @@
1
- import { newE2EPage } from "@stencil/core/testing";
2
- import { AxePuppeteer } from "@axe-core/puppeteer";
3
- describe("wm-chart", () => {
4
- let page,
5
- // @ts-ignore for some reason ts says it's unused
6
- component,
7
- // slices: NodeList,
8
- paths, svg;
9
- beforeEach(async () => {
10
- page = await newE2EPage();
11
- await page.setContent(`<html lang='en'><head><title>Page</title></head><body><main><h1>Title</h1>
12
- <wm-chart label="the label"><wm-chart-slice amount="70" legend="Created"></wm-chart-slice><wm-chart-slice amount="2" legend="Not Created"></wm-chart-slice></wm-chart>
13
- </main></body></html>`);
14
- component = await page.find("wm-chart");
15
- svg = await page.find("wm-chart >>> svg");
16
- // slices = await page.findAll("wm-chart-slice");
17
- paths = await page.findAll("wm-chart >>> path");
18
- });
19
- it("passes Axe tests", async () => {
20
- const results = await new AxePuppeteer(page).analyze();
21
- expect(results.violations.length).toBe(0);
22
- });
23
- it("renders", async () => {
24
- expect(svg).toBeTruthy();
25
- });
26
- it("renders the right amount of slices and text", async () => {
27
- let tmpPage = await newE2EPage();
28
- await tmpPage.setContent(`<wm-chart label="the label">
29
- <wm-chart-slice amount="100" legend="Created"></wm-chart-slice>
30
- <wm-chart-slice amount="123" legend="Created"></wm-chart-slice>
31
- <wm-chart-slice amount="0" legend="Maybe Created"></wm-chart-slice>
32
- </wm-chart>`);
33
- let tmpSlices = await tmpPage.findAll("wm-chart-slice");
34
- let tmpPaths = await tmpPage.findAll("wm-chart >>> path");
35
- let tmpTexts = await tmpPage.findAll("wm-chart >>> text.value");
36
- expect(tmpSlices.length).toEqual(3);
37
- // slices rendered even if amount === 0 for accessibility reasons
38
- expect(tmpPaths.length).toEqual(tmpSlices.length);
39
- expect(tmpTexts.length).toEqual(tmpSlices.length - 1);
40
- });
41
- it("hides clustered small numbers", async () => {
42
- // rule: num < 4 && either neighbor < 5
43
- let page = await newE2EPage();
44
- await page.setContent(`<wm-chart id="one" label="the label" chart-type="doughnut3">
45
- <wm-chart-slice amount="75" legend="A"></wm-chart-slice> // 89%
46
- <wm-chart-slice amount="5" legend="B"></wm-chart-slice> // 6%
47
- <wm-chart-slice amount="4" legend="C"></wm-chart-slice> // 5%
48
- </wm-chart>
49
- <wm-chart id="two" label="the label" chart-type="doughnut3">
50
- <wm-chart-slice amount="65" legend="A"></wm-chart-slice> // 69%
51
- <wm-chart-slice amount="14" legend="B"></wm-chart-slice> // 15%
52
- <wm-chart-slice amount="4" legend="C"></wm-chart-slice> // 4%
53
- <wm-chart-slice amount="4" legend="D"></wm-chart-slice> // 4%
54
- <wm-chart-slice amount="4" legend="E"></wm-chart-slice> // 4%
55
- <wm-chart-slice amount="3" legend="F"></wm-chart-slice> // 3%
56
- </wm-chart>
57
- <wm-chart id="three" label="the label" chart-type="doughnut3">
58
- <wm-chart-slice amount="83" legend="A"></wm-chart-slice> // 83%
59
- <wm-chart-slice amount="7" legend="B"></wm-chart-slice> // 7%
60
- <wm-chart-slice amount="6" legend="C"></wm-chart-slice> // 6%
61
- <wm-chart-slice amount="3" legend="D"></wm-chart-slice> // 3%
62
- <wm-chart-slice amount="1" legend="E"></wm-chart-slice> // 1%
63
- <wm-chart-slice amount="0" legend="F"></wm-chart-slice> // 0%
64
- </wm-chart>`);
65
- let [one, two, three] = await page.findAll("wm-chart");
66
- let oneSlices = await one.findAll("wm-chart-slice");
67
- let onePaths = await page.findAll("#one >>> path");
68
- let oneTexts = await page.findAll("#one >>> text.value");
69
- expect(onePaths.length).toEqual(oneSlices.length);
70
- // All vals should show incl. small ones
71
- // (they are not neighbors to other small vals)
72
- expect(oneTexts.length).toEqual(oneSlices.length);
73
- let twoSlices = await two.findAll("wm-chart-slice");
74
- let twoPaths = await page.findAll("#two >>> path");
75
- let twoTexts = await page.findAll("#two >>> text.value");
76
- expect(twoPaths.length).toEqual(twoSlices.length);
77
- // 1 small val should be hidden (3%)
78
- // because it is < 4 and has a neighbor < 5
79
- expect(twoTexts.length).toEqual(twoSlices.length - 1);
80
- let threeSlices = await three.findAll("wm-chart-slice");
81
- let threePaths = await page.findAll("#three >>> path");
82
- let threeTexts = await page.findAll("#three >>> text.value");
83
- // 3 small values should be hidden
84
- expect(threePaths.length).toEqual(threeSlices.length);
85
- expect(threeTexts.length).toEqual(threeSlices.length - 3);
86
- });
87
- it("handles percentages less than 1", async () => {
88
- let page = await newE2EPage();
89
- await page.setContent(`<wm-chart id="one" label="the label" chart-type="doughnut3">
90
- // total 284
91
- <wm-chart-slice amount="209" legend="A"></wm-chart-slice> // 74%
92
- <wm-chart-slice amount="40" legend="B"></wm-chart-slice> // 14%
93
- <wm-chart-slice amount="20" legend="C"></wm-chart-slice> // 7%
94
- <wm-chart-slice amount="14" legend="D"></wm-chart-slice> // 5%
95
- <wm-chart-slice amount="1" legend="E"></wm-chart-slice> // <1%
96
- </wm-chart>
97
- <wm-chart id="two" label="the label" chart-type="doughnut3">
98
- // total 284
99
- <wm-chart-slice amount="209" legend="A"></wm-chart-slice> // 73%
100
- <wm-chart-slice amount="40" legend="B"></wm-chart-slice> // 14%
101
- <wm-chart-slice amount="34" legend="C"></wm-chart-slice> // 12%
102
- <wm-chart-slice amount="1" legend="D"></wm-chart-slice> // <1%
103
- </wm-chart>`);
104
- let [one, two] = await page.findAll("wm-chart");
105
- let oneSlices = await one.findAll("wm-chart-slice");
106
- let onePaths = await page.findAll("#one >>> path");
107
- let oneTexts = await page.findAll("#one >>> text.value");
108
- expect(oneSlices.length).toEqual(5);
109
- // All paths are rendered
110
- expect(onePaths.length).toEqual(oneSlices.length);
111
- // E should be hidden because it borders a percentage < 8
112
- expect(oneTexts.length).toEqual(oneSlices.length - 1);
113
- let twoSlices = await two.findAll("wm-chart-slice");
114
- let twoPaths = await page.findAll("#two >>> path");
115
- let twoTexts = await page.findAll("#two >>> text.value");
116
- expect(twoSlices.length).toEqual(4);
117
- // All paths are rendered
118
- expect(twoPaths.length).toEqual(twoSlices.length);
119
- // Even D should be visible because it borders a percentage > 8
120
- expect(twoTexts.length).toEqual(twoSlices.length);
121
- });
122
- it("sets the subinfo value", async () => {
123
- const comp = await page.find("wm-chart");
124
- comp.setProperty("subinfo", "subinfo text");
125
- await page.waitForChanges();
126
- const subinfo = await page.find("wm-chart >>> .subinfo");
127
- expect(subinfo.textContent).toEqual("subinfo text");
128
- });
129
- it("changes the display values", async () => {
130
- // type bar2 and bar3
131
- const tmpPage = await newE2EPage();
132
- await tmpPage.setContent(`<wm-chart id="bar2chart" chart-type="bar2" label="the label" value-format="percentage"><wm-chart-slice amount="10" legend="Created"></wm-chart-slice><wm-chart-slice amount="10" legend="Not Created"></wm-chart-slice></wm-chart>
133
- <wm-chart id="bar3chart" chart-type="bar3" label="the label" value-format="amount"><wm-chart-slice amount="70" legend="Created"></wm-chart-slice><wm-chart-slice amount="10" legend="Not Created"></wm-chart-slice></wm-chart>`);
134
- await tmpPage.waitForChanges();
135
- const bar2val = await tmpPage.findAll("#bar2chart >>> .value");
136
- expect(bar2val[0].textContent).toEqual("50%");
137
- const bar3val = await tmpPage.findAll("#bar3chart >>> .value");
138
- expect(bar3val[0].textContent).toEqual("70");
139
- });
140
- it("handles Arrows and Tab keys", async () => {
141
- const componentWrapper = await page.find("wm-chart >>> .component-wrapper");
142
- await page.keyboard.press("Tab");
143
- await page.waitForChanges();
144
- await page.keyboard.press("ArrowDown");
145
- await page.waitForChanges();
146
- paths = await page.findAll("wm-chart >>> path");
147
- expect(componentWrapper).toEqualAttribute("tabindex", "-1");
148
- expect(paths[0]).toEqualAttribute("tabindex", "0");
149
- expect(paths[1]).toEqualAttribute("tabindex", "-1");
150
- await page.keyboard.press("ArrowRight");
151
- await page.waitForChanges();
152
- paths = await page.findAll("wm-chart >>> path");
153
- expect(componentWrapper).toEqualAttribute("tabindex", "-1");
154
- expect(paths[0]).toEqualAttribute("tabindex", "-1");
155
- expect(paths[1]).toEqualAttribute("tabindex", "0");
156
- await page.keyboard.press("ArrowLeft");
157
- await page.waitForChanges();
158
- paths = await page.findAll("wm-chart >>> path");
159
- expect(componentWrapper).toEqualAttribute("tabindex", "-1");
160
- expect(paths[0]).toEqualAttribute("tabindex", "0");
161
- expect(paths[1]).toEqualAttribute("tabindex", "-1");
162
- await page.keyboard.press("ArrowUp");
163
- await page.waitForChanges();
164
- paths = await page.findAll("wm-chart >>> path");
165
- expect(componentWrapper).toEqualAttribute("tabindex", "-1");
166
- expect(paths[0]).toEqualAttribute("tabindex", "-1");
167
- expect(paths[1]).toEqualAttribute("tabindex", "0");
168
- await page.keyboard.press("Tab");
169
- await page.waitForChanges();
170
- expect(componentWrapper).toEqualAttribute("tabindex", "0");
171
- expect(paths[0]).toEqualAttribute("tabindex", "-1");
172
- expect(paths[1]).toEqualAttribute("tabindex", "-1");
173
- });
174
- it("opens popover when slice clicked", async () => {
175
- const tmpPage = await newE2EPage();
176
- await tmpPage.setContent(`<wm-chart id="one" label="the label" chart-type="doughnut3">
177
- <wm-chart-slice amount="95" popover-title="A" popover-text="Text A" popover-button-text="A Button" legend="A"></wm-chart-slice>
178
- <wm-chart-slice amount="5" popover-title="B" popover-text="Text B" popover-button-text="B Button" legend="B"></wm-chart-slice>
179
- </wm-chart>`);
180
- await tmpPage.waitForChanges;
181
- let hasPopover = await tmpPage.find("wm-chart >>> .popover");
182
- const path = await tmpPage.find("wm-chart >>> path");
183
- expect(hasPopover).toBeFalsy;
184
- await path.click();
185
- await tmpPage.waitForChanges();
186
- hasPopover = await tmpPage.find("wm-chart >>> .popover");
187
- expect(hasPopover).toBeTruthy;
188
- });
189
- it("activating popover button fires event", async () => {
190
- const tmpPage = await newE2EPage();
191
- await tmpPage.setContent(`<wm-chart id="one" label="the label" chart-type="doughnut3">
192
- <wm-chart-slice amount="5" popover-title="A" popover-text="Text A" popover-button-text="A Button" legend="A"></wm-chart-slice>
193
- <wm-chart-slice amount="95" popover-title="B" popover-text="Text B" popover-button-text="B Button" legend="B"></wm-chart-slice>
194
- </wm-chart>
195
- <div id="indicator"></div>`);
196
- await tmpPage.waitForChanges;
197
- await tmpPage.evaluate(async () => {
198
- const component = await document.querySelector("wm-chart");
199
- const indicator = await document.querySelector("#indicator");
200
- await component.addEventListener("wmChartPopoverButtonTriggered", () => (indicator.textContent = "event heard"));
201
- });
202
- await tmpPage.waitForChanges;
203
- const indicator = await tmpPage.find("#indicator");
204
- expect(indicator.textContent).toBe("");
205
- await tmpPage.keyboard.press("Tab");
206
- await tmpPage.waitForChanges();
207
- await tmpPage.keyboard.press("ArrowDown");
208
- await tmpPage.waitForChanges();
209
- await tmpPage.keyboard.press("Enter");
210
- await tmpPage.waitForChanges();
211
- expect(indicator.textContent).toBe("event heard");
212
- });
213
- });
@@ -1,37 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import * as globalFuncs from "../../../global/functions";
3
- jest.spyOn(globalFuncs, "generateId");
4
- // @ts-ignore
5
- globalFuncs.generateId.mockImplementation(() => "random-id");
6
- import { Chart } from "./wm-chart";
7
- // mock ResizeObserver
8
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
9
- observe: jest.fn(),
10
- unobserve: jest.fn(),
11
- disconnect: jest.fn(),
12
- }));
13
- describe("wm-chart", () => {
14
- it("builds", async () => {
15
- const page = await newSpecPage({ components: [Chart], html: '<wm-chart label="charty"></wm-chart>' });
16
- expect(page.root).toMatchSnapshot();
17
- });
18
- it("properties and attributes", async () => {
19
- const page = await newSpecPage({ components: [Chart], html: '<wm-chart label="charty"></wm-chart>' });
20
- const componentWrapper = page.root.shadowRoot.querySelector(".component-wrapper");
21
- expect(componentWrapper).toEqualAttribute("role", "application");
22
- expect(componentWrapper).toEqualAttribute("aria-label", "charty");
23
- expect(componentWrapper).toEqualAttribute("aria-roledescription", "Interactive chart");
24
- expect(componentWrapper).toEqualAttribute("aria-describedby", "chart-instructions");
25
- });
26
- // needs refactoring before it can be tested
27
- // it("generates the svg path", () => {
28
- // const chart = new Chart();
29
- // expect(chart.getPathData(122, 23)).toEqual("thing");
30
- // })
31
- // needs refactoring before it can be tested
32
- // it("outputs the svg arc syntax", () => {
33
- // const chart = new Chart();
34
- // // the 2nd arc is set according to whether we're drawing the inner or outer arc, and whether it's concave or convex
35
- // expect(chart.getArc(23, "0 1", 34, 66)).toEqual("nene");
36
- // })
37
- });
@@ -1,176 +0,0 @@
1
- import { newE2EPage } from "@stencil/core/testing";
2
- import { AxePuppeteer } from "@axe-core/puppeteer";
3
- describe("wm-line-chart", () => {
4
- let page;
5
- async function createPageHelper() {
6
- page = await newE2EPage();
7
- await page.setContent(`<html lang='en'><head><title>Page</title></head><body><main><h1>Title</h1>
8
- <wm-line-chart
9
- label="Regional Job Trends"
10
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
11
- x-axis-label="Year"
12
- y-axis-label="Change Since 2020"
13
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13, "2023": null, "2024": 20, "2025": 23, "2026": 25, "2027": 32, "2028": 35, "2029": 40, "2030": 42, "2031": 52, "2032": 54, "2033": 61}, "National": {"2020": 8, "2021": 13, "2022": 16, "2023": 21, "2024": 23, "2025": 26, "2026": 28, "2027": 29, "2028": 32, "2029": 35, "2030": 39, "2031": 49, "2032": 51, "2033": 58} }'
14
- units="year,%"
15
- show-deltas="true"
16
- y-range="0,25,50,75,100"
17
- highlight-start="2026"
18
- visibility-toggles="true"
19
- >
20
- </wm-line-chart>
21
- </main></body></html>`);
22
- }
23
- it("passes Axe tests", async () => {
24
- await createPageHelper();
25
- const results = await new AxePuppeteer(page).analyze();
26
- expect(results.violations.length).toBe(0);
27
- });
28
- it("has keyboard navigation for legend", async () => {
29
- await createPageHelper();
30
- // first focus goes to first button
31
- await page.keyboard.press("Tab");
32
- await page.waitForChanges();
33
- let activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
34
- await page.waitForChanges();
35
- expect(activeElId).toBe("visibility-button-0");
36
- // wraps right
37
- await page.keyboard.press("ArrowLeft");
38
- await page.waitForChanges();
39
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
40
- await page.waitForChanges();
41
- expect(activeElId).toBe("visibility-button-1");
42
- await page.keyboard.press("ArrowLeft");
43
- await page.waitForChanges();
44
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
45
- await page.waitForChanges();
46
- expect(activeElId).toBe("visibility-button-0");
47
- await page.keyboard.press("ArrowRight");
48
- await page.waitForChanges();
49
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
50
- await page.waitForChanges();
51
- expect(activeElId).toBe("visibility-button-1");
52
- // wraps left
53
- await page.keyboard.press("ArrowRight");
54
- await page.waitForChanges();
55
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
56
- await page.waitForChanges();
57
- expect(activeElId).toBe("visibility-button-0");
58
- });
59
- it("has keyboard navigation for data points", async () => {
60
- page = await newE2EPage();
61
- await page.setContent(`<html lang='en'><head><title>Page</title></head><body><main><h1>Title</h1>
62
- <wm-line-chart
63
- label="Regional Job Trends"
64
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
65
- x-axis-label="Year"
66
- y-axis-label="Change Since 2020"
67
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13}, "National": {"2020": 8, "2021": null, "2022": 16}}'
68
- y-range="0,25,50,75,100"
69
- >
70
- </wm-line-chart>
71
- </main></body></html>`);
72
- await page.keyboard.press("Tab");
73
- await page.waitForChanges();
74
- let activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
75
- expect(activeElId).toBe("Regional-0");
76
- await page.keyboard.press("ArrowRight");
77
- await page.waitForChanges();
78
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
79
- await page.waitForChanges();
80
- expect(activeElId).toBe("Regional-1");
81
- await page.keyboard.press("ArrowRight");
82
- await page.waitForChanges();
83
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
84
- expect(activeElId).toBe("Regional-2");
85
- // wraps left
86
- await page.keyboard.press("ArrowRight");
87
- await page.waitForChanges();
88
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
89
- expect(activeElId).toBe("Regional-0");
90
- // wraps Left
91
- await page.keyboard.press("ArrowLeft");
92
- await page.waitForChanges();
93
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
94
- expect(activeElId).toBe("Regional-2");
95
- await page.keyboard.press("ArrowLeft");
96
- await page.waitForChanges();
97
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
98
- expect(activeElId).toBe("Regional-1");
99
- // next line
100
- await page.keyboard.press("ArrowLeft");
101
- await page.waitForChanges();
102
- await page.keyboard.press("ArrowDown");
103
- await page.waitForChanges();
104
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
105
- expect(activeElId).toBe("National-0");
106
- // skips null data point
107
- await page.keyboard.press("ArrowLeft");
108
- await page.waitForChanges();
109
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
110
- expect(activeElId).toBe("National-2");
111
- // wraps to first line
112
- await page.keyboard.press("ArrowLeft");
113
- await page.waitForChanges();
114
- await page.keyboard.press("ArrowDown");
115
- await page.waitForChanges();
116
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
117
- expect(activeElId).toBe("Regional-0");
118
- // wraps to last line
119
- await page.keyboard.press("ArrowUp");
120
- await page.waitForChanges();
121
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
122
- expect(activeElId).toBe("National-0");
123
- await page.keyboard.press("ArrowUp");
124
- await page.waitForChanges();
125
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
126
- expect(activeElId).toBe("Regional-0");
127
- });
128
- it("visibility toggle hides lines, data points are skipped by navigation", async () => {
129
- page = await newE2EPage();
130
- await page.setContent(`<html lang='en'><head><title>Page</title></head><body><main><h1>Title</h1>
131
- <wm-line-chart
132
- label="Regional Job Trends"
133
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
134
- x-axis-label="Year"
135
- y-axis-label="Change Since 2020"
136
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13}, "National": {"2020": 8, "2021": 12, "2022": 16}, "International": {"2020": 8, "2021": 12, "2022": 16}}'
137
- visibility-toggles="true"
138
- >
139
- </wm-line-chart>
140
- </main></body></html>`);
141
- const allLineEls = await page.findAll("wm-line-chart >>> .line");
142
- expect(allLineEls[0]).not.toHaveClass("hidden");
143
- await page.keyboard.press("Tab");
144
- await page.waitForChanges();
145
- // Enter key toggles button
146
- await page.keyboard.press("Enter");
147
- await page.waitForChanges();
148
- expect(allLineEls[0]).toHaveClass("hidden");
149
- // Space key toggles button
150
- await page.keyboard.press("Space");
151
- await page.waitForChanges();
152
- expect(allLineEls[0]).not.toHaveClass("hidden");
153
- await page.keyboard.press("Space");
154
- await page.waitForChanges();
155
- expect(allLineEls[0]).toHaveClass("hidden");
156
- // tab focuses first visible data point
157
- await page.keyboard.press("Tab");
158
- await page.waitForChanges();
159
- let activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
160
- expect(activeElId).toBe("National-0");
161
- await page.keyboard.press("ArrowDown");
162
- await page.waitForChanges();
163
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
164
- expect(activeElId).toBe("International-0");
165
- // data point nav skips hidden line
166
- await page.keyboard.press("ArrowDown");
167
- await page.waitForChanges();
168
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
169
- expect(activeElId).toBe("National-0");
170
- // data point nav skips hidden line
171
- await page.keyboard.press("ArrowUp");
172
- await page.waitForChanges();
173
- activeElId = await page.evaluate(() => document.activeElement.shadowRoot.activeElement.id);
174
- expect(activeElId).toBe("International-0");
175
- });
176
- });
@@ -1,163 +0,0 @@
1
- import { newSpecPage } from "@stencil/core/testing";
2
- import { LineChart } from "./wm-line-chart";
3
- // import * as globalFuncs from "../../../global/functions";
4
- // jest.spyOn(globalFuncs, "generateId");
5
- // // @ts-ignore
6
- // globalFuncs.generateId.mockImplementation(() => "random-id");
7
- // mock ResizeObserver
8
- global.ResizeObserver = jest.fn().mockImplementation(() => ({
9
- observe: jest.fn(),
10
- unobserve: jest.fn(),
11
- disconnect: jest.fn(),
12
- }));
13
- async function createPageHelper() {
14
- return await newSpecPage({
15
- components: [LineChart],
16
- html: `<wm-line-chart
17
- label="Regional Job Trends"
18
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
19
- x-axis-label="Year"
20
- y-axis-label="Change Since 2020"
21
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13, "2023": null, "2024": 20, "2025": 23, "2026": 25, "2027": 32, "2028": 35, "2029": 40, "2030": 42, "2031": 52, "2032": 54, "2033": 61}, "National": {"2020": 8, "2021": 13, "2022": 16, "2023": 21, "2024": 23, "2025": 26, "2026": 28, "2027": 29, "2028": 32, "2029": 35, "2030": 39, "2031": 49, "2032": 51, "2033": 58} }'
22
- units="year,%"
23
- show-deltas="true"
24
- y-range="0,25,50,75,100"
25
- highlight-start="2026"
26
- >
27
- </wm-line-chart>`,
28
- });
29
- }
30
- describe("Line Chart", () => {
31
- let page;
32
- it("builds", async () => {
33
- page = await createPageHelper();
34
- expect(page.root).toMatchSnapshot();
35
- });
36
- it("has proper aria properties and attributes", async () => {
37
- page = await createPageHelper();
38
- const componentWrapperEl = await page.root.shadowRoot.querySelector(".component-wrapper");
39
- expect(componentWrapperEl).toEqualAttribute("role", "application");
40
- expect(componentWrapperEl).toEqualAttribute("aria-roledescription", "Interactive chart");
41
- expect(componentWrapperEl).toEqualAttribute("aria-label", "Regional Job Trends");
42
- expect(componentWrapperEl).toEqualAttribute("aria-describedby", "chart-description");
43
- const firstPointEl = await page.root.shadowRoot.querySelector(".point");
44
- expect(firstPointEl).toEqualAttribute("role", "img");
45
- });
46
- it("plots all non-null data points", async () => {
47
- page = await newSpecPage({
48
- components: [LineChart],
49
- html: `<wm-line-chart
50
- label="Regional Job Trends"
51
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
52
- x-axis-label="Year"
53
- y-axis-label="Change Since 2020"
54
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13, "2023": 15, "2024": 20}, "National": {"2020": 8, "2021": 13, "2022": null, "2023": 21, "2024": 23}, "International": {"2020": 8, "2021": null, "2022": null, "2023": 21, "2024": 23} }'
55
- >
56
- </wm-line-chart>`,
57
- });
58
- const allPointEls = await page.root.shadowRoot.querySelectorAll(".point");
59
- const allLineEls = await page.root.shadowRoot.querySelectorAll(".line");
60
- const firstLinePointEls = await allLineEls[0].querySelectorAll(".point");
61
- const firstLineLineEls = await allLineEls[0].querySelectorAll("line");
62
- const secondLinePointEls = await allLineEls[1].querySelectorAll(".point");
63
- const secondLineLineEls = await allLineEls[1].querySelectorAll("line");
64
- const thirdLinePointEls = await allLineEls[2].querySelectorAll(".point");
65
- const thirdLineLineEls = await allLineEls[2].querySelectorAll("line");
66
- // each line has 5 intervals
67
- // first line has 0 nulls
68
- // second line has 1 null
69
- // third line has 2 nulls
70
- expect(allPointEls.length).toBe(12);
71
- expect(firstLinePointEls.length).toBe(5);
72
- expect(firstLineLineEls.length).toBe(4);
73
- expect(secondLinePointEls.length).toBe(4);
74
- expect(secondLineLineEls.length).toBe(2);
75
- expect(thirdLinePointEls.length).toBe(3);
76
- expect(thirdLineLineEls.length).toBe(1);
77
- });
78
- it("calculates deltas correctly", async () => {
79
- const component = await new LineChart();
80
- let previousPoint = {
81
- lineLabel: "fake label",
82
- xValue: "2020",
83
- yValue: 999,
84
- xPositionPercent: 0,
85
- yPositionPercent: 10,
86
- highlighted: false,
87
- };
88
- let currentPoint = {
89
- lineLabel: "fake label",
90
- xValue: "2021",
91
- yValue: 999,
92
- xPositionPercent: 20,
93
- yPositionPercent: 12,
94
- highlighted: false,
95
- };
96
- previousPoint.yValue = 10;
97
- currentPoint.yValue = 12;
98
- expect(component.calcDelta(currentPoint, previousPoint)).toBe("+20%");
99
- previousPoint.yValue = 10;
100
- currentPoint.yValue = 7;
101
- expect(component.calcDelta(currentPoint, previousPoint)).toBe("-30%");
102
- previousPoint.yValue = 12;
103
- currentPoint.yValue = 10;
104
- expect(component.calcDelta(currentPoint, previousPoint)).toBe("-16.67%");
105
- previousPoint.yValue = 0;
106
- currentPoint.yValue = 1;
107
- expect(component.calcDelta(currentPoint, previousPoint)).toBe("-");
108
- previousPoint.yValue = 17;
109
- currentPoint.yValue = 0;
110
- expect(component.calcDelta(currentPoint, previousPoint)).toBe("-100%");
111
- });
112
- it("uses label-width to set y-axis label width", async () => {
113
- page = await newSpecPage({
114
- components: [LineChart],
115
- html: `<wm-line-chart
116
- label="Regional Job Trends"
117
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
118
- x-axis-label="Year"
119
- y-axis-label="Change Since 2020"
120
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13, "2023": null, "2024": 20, "2025": 23, "2026": 25, "2027": 32, "2028": 35, "2029": 40, "2030": 42, "2031": 52, "2032": 54, "2033": 61}, "National": {"2020": 8, "2021": 13, "2022": 16, "2023": 21, "2024": 23, "2025": 26, "2026": 28, "2027": 29, "2028": 32, "2029": 35, "2030": 39, "2031": 49, "2032": 51, "2033": 58} }'
121
- >
122
- </wm-line-chart>`,
123
- });
124
- let yAxisLabel = await page.root.shadowRoot.querySelector(".--y-axis");
125
- expect(yAxisLabel.style.cssText).toBe("--labelWidth: 120px;");
126
- page = await newSpecPage({
127
- components: [LineChart],
128
- html: `<wm-line-chart
129
- label="Regional Job Trends"
130
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
131
- x-axis-label="Year"
132
- y-axis-label="Change Since 2020"
133
- line-data='{"Regional": {"2020": 5, "2021": 10, "2022": 13, "2023": null, "2024": 20, "2025": 23, "2026": 25, "2027": 32, "2028": 35, "2029": 40, "2030": 42, "2031": 52, "2032": 54, "2033": 61}, "National": {"2020": 8, "2021": 13, "2022": 16, "2023": 21, "2024": 23, "2025": 26, "2026": 28, "2027": 29, "2028": 32, "2029": 35, "2030": 39, "2031": 49, "2032": 51, "2033": 58} }'
134
- label-width="23%"
135
- >
136
- </wm-line-chart>`,
137
- });
138
- yAxisLabel = await page.root.shadowRoot.querySelector(".--y-axis");
139
- expect(yAxisLabel.style.cssText).toBe("--labelWidth: 23%;");
140
- });
141
- it("sets custom y-range if provided, abbreviates y-axis numbers of thousands", async () => {
142
- page = await newSpecPage({
143
- components: [LineChart],
144
- html: `<wm-line-chart
145
- label="Regional Job Trends"
146
- description="View job trends for your region compared to national tends from the past 3 years with a 3 year projection"
147
- x-axis-label="Year"
148
- y-axis-label="Change Since 2020"
149
- line-data='{"Regional": {"2020": -10000, "2021": 10900, "2022": 40200} }'
150
- y-range="-13300,0,100,10000,20945,30099,40520"
151
- >
152
- </wm-line-chart>`,
153
- });
154
- const yIntervals = await page.root.shadowRoot.querySelectorAll(".y-interval");
155
- expect(yIntervals[0].textContent).toBe("40.5K");
156
- expect(yIntervals[1].textContent).toBe("30.1K");
157
- expect(yIntervals[2].textContent).toBe("20.9K");
158
- expect(yIntervals[3].textContent).toBe("10K");
159
- expect(yIntervals[4].textContent).toBe("100");
160
- expect(yIntervals[5].textContent).toBe("0");
161
- expect(yIntervals[6].textContent).toBe("-13.3K");
162
- });
163
- });