1 | import { Assertion, JestFriendlyAssertion } from '../assertion';
|
2 | import { StackInspector } from '../inspector';
|
3 | /**
|
4 | * Magic value to signify that a certain key should be absent from the property bag.
|
5 | *
|
6 | * The property is either not present or set to `undefined.
|
7 | *
|
8 | * NOTE: `ABSENT` only works with the `haveResource()` and `haveResourceLike()`
|
9 | * assertions.
|
10 | */
|
11 | export declare const ABSENT = "{{ABSENT}}";
|
12 | /**
|
13 | * An assertion to check whether a resource of a given type and with the given properties exists, disregarding properties
|
14 | *
|
15 | * @param resourceType the type of the resource that is expected to be present.
|
16 | * @param properties the properties that the resource is expected to have. A function may be provided, in which case
|
17 | * it will be called with the properties of candidate resources and an ``InspectionFailure``
|
18 | * instance on which errors should be appended, and should return a truthy value to denote a match.
|
19 | * @param comparison the entity that is being asserted against.
|
20 | * @param allowValueExtension if properties is an object, tells whether values must match exactly, or if they are
|
21 | * allowed to be supersets of the reference values. Meaningless if properties is a function.
|
22 | */
|
23 | export declare function haveResource(resourceType: string, properties?: any, comparison?: ResourcePart, allowValueExtension?: boolean): Assertion<StackInspector>;
|
24 | /**
|
25 | * Sugar for calling ``haveResource`` with ``allowValueExtension`` set to ``true``.
|
26 | */
|
27 | export declare function haveResourceLike(resourceType: string, properties?: any, comparison?: ResourcePart): Assertion<StackInspector>;
|
28 | export declare type PropertyMatcher = (props: any, inspection: InspectionFailure) => boolean;
|
29 | export declare class HaveResourceAssertion extends JestFriendlyAssertion<StackInspector> {
|
30 | private readonly resourceType;
|
31 | private readonly inspected;
|
32 | private readonly part;
|
33 | private readonly matcher;
|
34 | constructor(resourceType: string, properties?: any, part?: ResourcePart, allowValueExtension?: boolean);
|
35 | assertUsing(inspector: StackInspector): boolean;
|
36 | generateErrorMessage(): string;
|
37 | assertOrThrow(inspector: StackInspector): void;
|
38 | get description(): string;
|
39 | }
|
40 | export interface InspectionFailure {
|
41 | resource: any;
|
42 | failureReason: string;
|
43 | }
|
44 | /**
|
45 | * What part of the resource to compare
|
46 | */
|
47 | export declare enum ResourcePart {
|
48 | /**
|
49 | * Only compare the resource's properties
|
50 | */
|
51 | Properties = 0,
|
52 | /**
|
53 | * Check the entire CloudFormation config
|
54 | *
|
55 | * (including UpdateConfig, DependsOn, etc.)
|
56 | */
|
57 | CompleteDefinition = 1
|
58 | }
|
59 | /**
|
60 | * Return whether `superObj` is a super-object of `obj`.
|
61 | *
|
62 | * A super-object has the same or more property values, recursing into sub properties if ``allowValueExtension`` is true.
|
63 | *
|
64 | * At any point in the object, a value may be replaced with a function which will be used to check that particular field.
|
65 | * The type of a matcher function is expected to be of type PropertyMatcher.
|
66 | *
|
67 | * @deprecated - Use `objectLike` or a literal object instead.
|
68 | */
|
69 | export declare function isSuperObject(superObj: any, pattern: any, errors?: string[], allowValueExtension?: boolean): boolean;
|