index.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import * as _angular_cdk_testing from '@angular/cdk/testing';
  2. import { BaseHarnessFilters, ComponentHarness, ComponentHarnessConstructor, HarnessPredicate } from '@angular/cdk/testing';
  3. /** A set of criteria that can be used to filter a list of `MatRadioGroupHarness` instances. */
  4. interface RadioGroupHarnessFilters extends BaseHarnessFilters {
  5. /** Only find instances whose name attribute is the given value. */
  6. name?: string;
  7. }
  8. /** A set of criteria that can be used to filter a list of `MatRadioButtonHarness` instances. */
  9. interface RadioButtonHarnessFilters extends BaseHarnessFilters {
  10. /** Only find instances whose label matches the given value. */
  11. label?: string | RegExp;
  12. /** Only find instances whose name attribute is the given value. */
  13. name?: string;
  14. /** Only find instances with the given checked value. */
  15. checked?: boolean;
  16. }
  17. /** Harness for interacting with a mat-radio-group in tests. */
  18. declare class MatRadioGroupHarness extends ComponentHarness {
  19. /** The selector for the host element of a `MatRadioGroup` instance. */
  20. static hostSelector: string;
  21. private _buttonClass;
  22. /**
  23. * Gets a `HarnessPredicate` that can be used to search for a radio group with specific
  24. * attributes.
  25. * @param options Options for filtering which radio group instances are considered a match.
  26. * @return a `HarnessPredicate` configured with the given options.
  27. */
  28. static with<T extends MatRadioGroupHarness>(this: ComponentHarnessConstructor<T>, options?: RadioGroupHarnessFilters): HarnessPredicate<T>;
  29. /** Gets the name of the radio-group. */
  30. getName(): Promise<string | null>;
  31. /** Gets the id of the radio-group. */
  32. getId(): Promise<string | null>;
  33. /** Gets the checked radio-button in a radio-group. */
  34. getCheckedRadioButton(): Promise<MatRadioButtonHarness | null>;
  35. /** Gets the checked value of the radio-group. */
  36. getCheckedValue(): Promise<string | null>;
  37. /**
  38. * Gets a list of radio buttons which are part of the radio-group.
  39. * @param filter Optionally filters which radio buttons are included.
  40. */
  41. getRadioButtons(filter?: RadioButtonHarnessFilters): Promise<MatRadioButtonHarness[]>;
  42. /**
  43. * Checks a radio button in this group.
  44. * @param filter An optional filter to apply to the child radio buttons. The first tab matching
  45. * the filter will be selected.
  46. */
  47. checkRadioButton(filter?: RadioButtonHarnessFilters): Promise<void>;
  48. /** Gets the name attribute of the host element. */
  49. private _getGroupNameFromHost;
  50. /** Gets a list of the name attributes of all child radio buttons. */
  51. private _getNamesFromRadioButtons;
  52. /** Checks if the specified radio names are all equal. */
  53. private _checkRadioNamesInGroupEqual;
  54. /**
  55. * Checks if a radio-group harness has the given name. Throws if a radio-group with
  56. * matching name could be found but has mismatching radio-button names.
  57. */
  58. protected static _checkRadioGroupName(harness: MatRadioGroupHarness, name: string): Promise<boolean>;
  59. }
  60. /** Harness for interacting with a mat-radio-button in tests. */
  61. declare class MatRadioButtonHarness extends ComponentHarness {
  62. /** The selector for the host element of a `MatRadioButton` instance. */
  63. static hostSelector: string;
  64. /**
  65. * Gets a `HarnessPredicate` that can be used to search for a radio button with specific
  66. * attributes.
  67. * @param options Options for filtering which radio button instances are considered a match.
  68. * @return a `HarnessPredicate` configured with the given options.
  69. */
  70. static with<T extends MatRadioButtonHarness>(this: ComponentHarnessConstructor<T>, options?: RadioButtonHarnessFilters): HarnessPredicate<T>;
  71. protected _textLabel: () => Promise<_angular_cdk_testing.TestElement>;
  72. protected _clickLabel: () => Promise<_angular_cdk_testing.TestElement>;
  73. private _input;
  74. /** Whether the radio-button is checked. */
  75. isChecked(): Promise<boolean>;
  76. /** Whether the radio-button is disabled. */
  77. isDisabled(): Promise<boolean>;
  78. /** Whether the radio-button is required. */
  79. isRequired(): Promise<boolean>;
  80. /** Gets the radio-button's name. */
  81. getName(): Promise<string | null>;
  82. /** Gets the radio-button's id. */
  83. getId(): Promise<string | null>;
  84. /**
  85. * Gets the value of the radio-button. The radio-button value will be converted to a string.
  86. *
  87. * Note: This means that for radio-button's with an object as a value `[object Object]` is
  88. * intentionally returned.
  89. */
  90. getValue(): Promise<string | null>;
  91. /** Gets the radio-button's label text. */
  92. getLabelText(): Promise<string>;
  93. /** Focuses the radio-button. */
  94. focus(): Promise<void>;
  95. /** Blurs the radio-button. */
  96. blur(): Promise<void>;
  97. /** Whether the radio-button is focused. */
  98. isFocused(): Promise<boolean>;
  99. /**
  100. * Puts the radio-button in a checked state by clicking it if it is currently unchecked,
  101. * or doing nothing if it is already checked.
  102. */
  103. check(): Promise<void>;
  104. }
  105. export { MatRadioButtonHarness, MatRadioGroupHarness };
  106. export type { RadioButtonHarnessFilters, RadioGroupHarnessFilters };