cumulocity-cypress
Version:
Cypress commands for Cumulocity IoT
85 lines (84 loc) • 3.37 kB
TypeScript
import { C8ySchemaMatcher } from "./schema";
/**
* Matcher for C8yPactRecord objects. Use C8yPactMatcher to match any two
* records. Depending on the matcher implementation an Error will be thrown
* or boolean is returned.
*/
export interface C8yPactMatcher {
/**
* Matches objectToMatch against objectPact. Returns false if objectToMatch
* does not match objectPact or throws an error with details on failing match.
*
* @param obj1 Object to match.
* @param obj2 Pact to match obj1 against.
* @param {C8yPactMatcherOptions} options The C8yPactMatcherOptions to use for matching.
*/
match: (objectToMatch: any, objectPact: any, options?: C8yPactMatcherOptions) => boolean;
}
export interface C8yPactMatcherOptions {
strictMatching?: boolean;
loggerProps?: {
[key: string]: any;
};
schemaMatcher?: C8ySchemaMatcher;
parents?: string[];
ignoreCase?: boolean;
}
/**
* Default implementation of C8yPactMatcher to match C8yPactRecord objects. Pacts
* are matched by comparing the properties of the objects using property matchers.
* If no property matcher is configured for a property, the property will be matched
* by equality. Disable Cypress.c8ypact.config.strictMatching to ignore properties that are
* missing in matched objects. In case objects do not match an C8yPactError is thrown.
*/
export declare class C8yDefaultPactMatcher implements C8yPactMatcher {
propertyMatchers: {
[key: string]: C8yPactMatcher;
};
static schemaMatcher: C8ySchemaMatcher;
constructor(propertyMatchers?: {
[key: string]: C8yPactMatcher;
});
match(obj1: any, obj2: any, options?: C8yPactMatcherOptions): boolean;
/**
* Returns the property matcher for the given property name.
* @param key The property name to get the matcher for.
* @param ignoreCase Whether to ignore the case of the property name.
*/
getPropertyMatcher(key: string, ignoreCase?: boolean): any;
/**
* Adds a new property matcher for the given property name.
*/
addPropertyMatcher(propertyName: string, matcher: C8yPactMatcher): void;
/**
* Removes the property matcher for the given property name.
*/
removePropertyMatcher(propertyName: string): void;
}
/**
* Extends C8yDefaultPactMatcher with default property matchers for Cumulocity
* response bodies. It has rules configured at least for the following properties:
* id, statistics, lastUpdated, creationTime, next, self, password, owner, tenantId
* and lastPasswordChange. It is registered for the properties body and requestBody.
*/
export declare class C8yPactBodyMatcher extends C8yDefaultPactMatcher {
constructor(propertyMatchers?: {});
}
export declare class C8yIdentifierMatcher implements C8yPactMatcher {
match(obj1: any, obj2: any): boolean;
}
export declare class C8yNumberMatcher implements C8yPactMatcher {
match(obj1: any, obj2: any): boolean;
}
export declare class C8yStringMatcher implements C8yPactMatcher {
match(obj1: any, obj2: any): boolean;
}
export declare class C8yIgnoreMatcher implements C8yPactMatcher {
match(): boolean;
}
export declare class C8ySameTypeMatcher implements C8yPactMatcher {
match(obj1: any, obj2: any): boolean;
}
export declare class C8yISODateStringMatcher {
match(obj1: any, obj2: any): boolean;
}