getAriaLabel.spec.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import getAriaLabel from './getAriaLabel';
  2. describe('getAriaLabel', () => {
  3. it.each([
  4. {
  5. element:
  6. 'button#ID1.classA[role="button"][aria="View More"][data-test-id="button-test"][alt="view more"][title="cool title"]',
  7. ariaLabel: 'View More',
  8. },
  9. {
  10. element:
  11. 'button#ID1.classA[role="button"][data-test-id="button-test"][alt="view more"][title="cool title"]',
  12. ariaLabel: '',
  13. },
  14. {
  15. element:
  16. 'button#ID1.classA[role="button"][aria="[Filtered]"][data-test-id="button-test"][alt="view more"][title="cool title"]',
  17. ariaLabel: '[Filtered]',
  18. },
  19. {
  20. element:
  21. 'button#ID1.classA[role="button"][aria="[]"][data-test-id="button-test"][alt="view more"][title="cool title"]',
  22. ariaLabel: '[]',
  23. },
  24. {
  25. element:
  26. 'button#ID1.classA[role="button"][aria=""][data-test-id="button-test"][alt="view more"][title="cool title"]',
  27. ariaLabel: '',
  28. },
  29. {
  30. element:
  31. 'button#ID1.classA[role="button"][aria="["][data-test-id="button-test"][alt="view more"][title="cool title"]',
  32. ariaLabel: '[',
  33. },
  34. {
  35. element:
  36. 'button#ID1.classA[role="button"][aria="]blah"][data-test-id="button-test"][alt="view more"][title="cool title"]',
  37. ariaLabel: ']blah',
  38. },
  39. {
  40. element:
  41. 'button#ID1.classA[role="button"][aria="""][data-test-id="button-test"][alt="view more"][title="cool title"]',
  42. ariaLabel: '"',
  43. },
  44. {
  45. element:
  46. 'button#ID1.classA[role="button"][aria="]""][data-test-id="button-test"][alt="view more"][title="cool title"]',
  47. ariaLabel: ']"',
  48. },
  49. ])(
  50. 'should construct the correct aria label for each element in the list',
  51. ({element, ariaLabel}) => {
  52. expect(getAriaLabel(element)).toStrictEqual(ariaLabel);
  53. }
  54. );
  55. });