asymmetricMatchers.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. */
  8. import type { AsymmetricMatcher as AsymmetricMatcherInterface, MatcherState } from './types';
  9. export declare abstract class AsymmetricMatcher<T, State extends MatcherState = MatcherState> implements AsymmetricMatcherInterface {
  10. protected sample: T;
  11. protected inverse: boolean;
  12. $$typeof: symbol;
  13. constructor(sample: T, inverse?: boolean);
  14. protected getMatcherContext(): State;
  15. abstract asymmetricMatch(other: unknown): boolean;
  16. abstract toString(): string;
  17. getExpectedType?(): string;
  18. toAsymmetricMatcher?(): string;
  19. }
  20. declare class Any extends AsymmetricMatcher<any> {
  21. constructor(sample: unknown);
  22. asymmetricMatch(other: unknown): boolean;
  23. toString(): string;
  24. getExpectedType(): string;
  25. toAsymmetricMatcher(): string;
  26. }
  27. declare class Anything extends AsymmetricMatcher<void> {
  28. asymmetricMatch(other: unknown): boolean;
  29. toString(): string;
  30. toAsymmetricMatcher(): string;
  31. }
  32. declare class ArrayContaining extends AsymmetricMatcher<Array<unknown>> {
  33. constructor(sample: Array<unknown>, inverse?: boolean);
  34. asymmetricMatch(other: Array<unknown>): boolean;
  35. toString(): string;
  36. getExpectedType(): string;
  37. }
  38. declare class ObjectContaining extends AsymmetricMatcher<Record<string, unknown>> {
  39. constructor(sample: Record<string, unknown>, inverse?: boolean);
  40. asymmetricMatch(other: any): boolean;
  41. toString(): string;
  42. getExpectedType(): string;
  43. }
  44. declare class StringContaining extends AsymmetricMatcher<string> {
  45. constructor(sample: string, inverse?: boolean);
  46. asymmetricMatch(other: string): boolean;
  47. toString(): string;
  48. getExpectedType(): string;
  49. }
  50. declare class StringMatching extends AsymmetricMatcher<RegExp> {
  51. constructor(sample: string | RegExp, inverse?: boolean);
  52. asymmetricMatch(other: string): boolean;
  53. toString(): string;
  54. getExpectedType(): string;
  55. }
  56. export declare const any: (expectedObject: unknown) => Any;
  57. export declare const anything: () => Anything;
  58. export declare const arrayContaining: (sample: Array<unknown>) => ArrayContaining;
  59. export declare const arrayNotContaining: (sample: Array<unknown>) => ArrayContaining;
  60. export declare const objectContaining: (sample: Record<string, unknown>) => ObjectContaining;
  61. export declare const objectNotContaining: (sample: Record<string, unknown>) => ObjectContaining;
  62. export declare const stringContaining: (expected: string) => StringContaining;
  63. export declare const stringNotContaining: (expected: string) => StringContaining;
  64. export declare const stringMatching: (expected: string | RegExp) => StringMatching;
  65. export declare const stringNotMatching: (expected: string | RegExp) => StringMatching;
  66. export {};