/// /// import selectors = require("./citra/selectors"); import { CookieJar } from "tough-cookie"; import { RequestInit } from "node-fetch"; export interface Project {} export declare let project: Project; export interface ChakramRequestOptions {} export interface RequestOptions { assertStatusCode?: number; debug?: boolean; noAssert?: boolean; skipContractValidation?: boolean; skipRequestContractValidation?: boolean; skipResponseContractValidation?: boolean; logFailedRequests?: boolean; params?: ChakramRequestOptions; } export interface PostRequestOptions extends RequestOptions { commit?: boolean; } export declare let config: import("./citra/main/config/config").ConfigAPI; export declare let post: typeof import("./citra/main/http/request").post; export declare let get: typeof import("./citra/main/http/request").get; export declare let del: typeof import("./citra/main/http/request").del; export declare let formdata: typeof import("./citra/main/http/request").formdata; export declare namespace poll { let poll_1: typeof import("./citra/main/poll/poll").poll; export { poll_1 as poll }; export let listResults: typeof import("./citra/main/poll/poll").pollListResults; } export declare let logger: { log: (...args: any[]) => void; error: (...args: any[]) => void; success: (...args: any[]) => void; pending: (...args: any[]) => void; }; export declare let log: (...args: any[]) => void; export declare let request: typeof import("./citra/main/http/requestBuilder").request; export declare namespace api { let uploadSingleFile: typeof import("./citra/api/single_file_upload").uploadSingleFile; let downloadSingleFile: typeof import("./citra/api/single_file_download").downloadSingleFile; } export declare namespace auth { let login: typeof import("./citra/auth/login").login; let logout: typeof import("./citra/auth/login").logout; let getJar: typeof import("./citra/auth/authSession").getJar; let getAuthSession: typeof import("./citra/auth/authSession").getAuthSession; let userdata: typeof import("./citra/auth/userdata").userdata; } export declare namespace util { let getSysdate: typeof import("./citra/util/dateTime").getSysdate; let mapToQueryString: typeof import("./citra/util/mapToQueryString").mapToQueryString; } export declare let expect: Chai.ExpectStatic; export declare let should: Chai.Should; export { selectors }; export declare namespace chakram { export interface ChakramResponse { error: Error; response: any; body: any; jar: CookieJar; url: string; responseTime: number; } export interface Chakram { name: string; } /** Add a new method assertion to Chakram. Methods should be used when the assertion requires parameters. * @param {string} name The plugin's name, used as an identifier * @plugin {Function} plugin A function which should accept one or more arguments. The first argument will be a ChakramResponse object, followed by any arguments passed into the assertion. * * @example * ``` * chakram.addMethod("statusRange", function (respObj, low, high) { * var inRange = respObj.response.statusCode >= low && respObj.response.statusCode <= high; * this.assert(inRange, 'expected '+respObj.response.statusCode+' to be between '+low+' and '+high, 'expected '+respObj.response.statusCode+' not to be between '+low+' and '+high); * }); * var twohundred = chakram.get("http://httpbin.org/status/200"); * return expect(twohundred).to.have.statusRange(0, 200); * ``` */ function addMethod(name: string, plugin: any): void; /** * Add a new property assertion to Chakram. Properties should be used over methods when there is no arguments required for the assertion. * * @param {string} name The plugin's name, used as an identifier * @param {any} plugin A function which should accept one argument; a ChakramResponse object * * @example * ``` * chakram.addProperty("httpbin", function (respObj) { * var hostMatches = /httpbin.org/.test(respObj.url); * this.assert(hostMatches, * 'expected '+respObj.url+' to contain httpbin.org', * 'expected '+respObj.url+' to not contain httpbin.org'); * }); * var httpbin = chakram.get("http://httpbin.org/status/200"); * return expect(httpbin).to.be.at.httpbin; * ``` */ function addProperty(name: string, plugin: any): void; /** * Add a raw chai plugin to Chakram. See Chai's documentation for more details. * * @param {string} name The plugin's name, used as an identifier * @param {any} plugin A Chai plugin function, function should accept two arguments, the chai object and the chai utils object * * @example * ``` * chakram.addRawPlugin("unavailable", function (chai, utils) { * utils.addProperty(chai.Assertion.prototype, 'unavailable', function () { * var statusCode = this._obj.response.statusCode; * this.assert(statusCode === 503, * 'expected status code '+statusCode+' to equal 503', * 'expected '+statusCode+' to not be equal to 503'); * }); * }); * var unavailableReq = chakram.get("http://httpbin.org/status/503"); * return expect(unavailableReq).to.be.unavailable; * ``` * */ function addRawPlugin(name: string, plugin: any): void; /** * Exposes tv4's add schema method. Allows the registration of schemas used for schema validation. * * @return {void} * * @example * ``` * chakram.addSchema('http://example.com/schema', { ... }); * ``` */ function addSchema(): void; /** * Exposes tv4's add format method. Allows add custom format for schema validation. * * @example * ``` * chakram.addSchemaFormat('decimal-digits', function (data, schema) { * if (typeof data === 'string' && !/^[0-9]+$/.test(data)) { * return null; * } * return "must be string of decimal digits"; * }); * ``` */ function addSchemaFormat(): void; /** * Returns a promise which is fulfilled once all promises in the provided array are fulfilled. Identical to Q.all. * * @param {Array} promises: Array of promises to wait for * * @return {Promise} Promise */ function all(promises: Promise[]): Promise; /** * Clears any previously set default options. */ function clearRequestDefaults(); /** * Perform HTTP DELETE request. * * @param {string} url fully qualified url * @param {any} data a JSON serializable object (unless json is set to false in params, in which case this should be a buffer or string) * @param {ChakramRequestOptions} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object */ function del( url: string, data: any, params?: ChakramRequestOptions, ): Promise; /** * Chakram assertion constructor. Extends chai's extend method with Chakram's HTTP assertions. Please see chai's API documentation for details on the default chai assertions and the ChakramExpectation documentation for the Chakram HTTP assertions. * * @example * ``` * var expect = chakram.expect; * it("should support chakram and chai assertions", function () { * var google = chakram.get("http://google.com"); * expect(true).to.be.true; * expect(google).to.have.status(200); * expect(1).to.be.below(10); * expect("teststring").to.be.a('string'); * return chakram.wait(); * }); * ``` */ const expect: Chai.ExpectStatic; /** * Exposes tv4's get schemaMap method. Allows to check the mapping schema object. * * @example * ``` * chakram.getSchemaMap(); * ``` */ function getSchemaMap(); /** * Perform HTTP HEAD request * @param {string} url fully qualified url * @param {RequestInit} [params] additional request options, see the popular fetch library for options */ function head(url: string, params?: ChakramRequestOptions): Promise; /** * Initialise the chakram package with custom chai plugins. This is no longer recommended, instead use either addMethod, addProperty or addRawPlugin. * * @param {ChaiPlugin} customChaiPlugin repeatable One or multiple chai plugins */ function initialize(customChaiPlugin): void; /** * Perform HTTP OPTIONS request * * @param {string} url fully qualified url * @param {RequestInit} [params] additional request options, see the popular node-fetch library for options */ function options(url: string, params?: ChakramRequestOptions): Promise; /** * Perform HTTP GET request * * @param {string} url fully qualified url * @param {RequestInit} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object * */ function get( url: string, params?: ChakramRequestOptions, ): Promise; /** * Perform HTTP HEAD request * * @param {string} url fully qualified url * @param {RequestInit} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object * */ function head( url: string, params?: ChakramRequestOptions, ): Promise; /** * Perform HTTP PATCH request * * @param {string} url fully qualified url * @param {any} data a JSON serializable object (unless json is set to false in params, in which case this should be a buffer or string) * @param {RequestInit} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object */ function patch( url: string, data: any, params?: ChakramRequestOptions, ): Promise; /** * Perform HTTP POST request * * @param {string} url fully qualified url * @param {any} data a JSON serializable object (unless json is set to false in params, in which case this should be a buffer or string) * @param {RequestInit} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object * */ function post( url: string, data: any, params?: ChakramRequestOptions, ): Promise; /** * Perform HTTP PUT request * * @param {string} url fully qualified url * @param {any} data a JSON serializable object (unless json is set to false in params, in which case this should be a buffer or string) * @param {RequestInit} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object */ function put( url: string, data: any, params?: ChakramRequestOptions, ): Promise; /** * Perform HTTP request * * @param {string} method the HTTP method to use * @param {string} url fully qualified url * @param {ChakramRequestOptions} [params] additional request options, see the popular node-fetch library for options * * @return {Promise} Promise which will resolve to a ChakramResponse object * * @example * ``` * var request = chakram.request("GET", "http://httpbin.org/get", { 'auth': {'user': 'username','pass': 'password'} }); expect(request).to.have.status(200); * ``` * */ function request( method: "GET" | "PUT" | "POST" | "OPTIONS", url: string, params?: RequestInit, ): Promise; /** * Sets the default options applied to all future requests. * * @param {RequestInit} options [options description] * * @return {void} [return description] */ function setRequestDefaults(options: RequestInit): void; /** * Activates debugging. By default, will print request and response details to the console. Custom debugging functions can be specified. * * @param {Function} [debugFn] A debug function which replaces the default log to console. */ function startDebug(debugFn?: Function): void; /** * Deactivates debugging */ function stopDebug(): void; /** * Returns a promise which is fulfilled once all chakram expectations are fulfilled. This works by recording all chakram expectations called within an 'it' and waits for all the expectations to finish before resolving the returned promise. * * @return {Promise} Promise; * * @example * ``` * it("should support auto waiting for tests", function() { var response = chakram.get("http://httpbin.org/get"); expect(response).to.have.status(200); expect(response).not.to.have.status(404); return chakram.wait(); }); * ``` */ function wait(): Promise; /** * Returns a promise which is fulfilled once all promises in the provided array are fulfilled. Similar to Q.all, however, instead of being fulfilled with an array containing the fulfillment value of each promise, it is fulfilled with the fulfillment value of the last promise in the provided array. This allows chaining of HTTP calls. * * @param {Array} promises: An array of promises to wait for * * @example * ``` * it("should support grouping multiple tests", function () { var response = chakram.get("http://httpbin.org/get"); return chakram.waitFor([ expect(response).to.have.status(200), expect(response).not.to.have.status(404) ]); }); * ``` * */ function waitFor(promises: Promise[]); } /** * Chakram assertions */ declare global { namespace Chai { interface Assertion { /** * Checks the response time of the response is less than or equal to the provided millisecond value. * * @param {number} code the expected status code from the response * * @return {Assertion} Assertion */ status(code: number): Assertion; /** * Checks the response time of the response is less than or equal to the provided millisecond value. * * @param {number} milliseconds the expected maximum response time in milliseconds * * @return {Assertion} [return description] */ responsetime(milliseconds: number): Assertion; /** * Checks that the response is deflate compressed */ deflate(); /** * Checks that the response is gzip compressed */ gzip(); /** * Either checks that a header exists or ensures the header matches a given value * * @param {string} name checks a header with this name exists * @param {[string | RegExp | Function]} [value] if specified, checks the header matches the given string or regular expression OR calls the provided function passing the header's value */ header(name: string, value?: string | RegExp | Function); /** * Checks the content of a JSON object within the return body. By default this will check the body JSON exactly matches the given object. If the 'comprise' chain element is used, it checks that the object specified is contained within the body JSON. An additional first argument allows sub object checks. * * @param {any} subelement if specified a subelement of the JSON body is checked, specified using dot notation * @param {any} expectedValue a JSON serializable object which should match the JSON body or the JSON body's subelement OR a custom function which is called with the JSON body or the JSON body's subelement */ json(subelement: string, expectedValue: any); /** * Checks the schema of the returned JSON object against a provided JSON Schema. This assertion utilizes the brilliant tv4 library. An optional dot notation argument allows a subelement of the JSON object to checked against a JSON schema. Amoungst others, this can confirm types, array lengths, required fields, min and max of numbers and string lengths. For more examples see the test/assertions/schema.js tests. * * @param {string} subelement if specified a subelement of the JSON body is checked, specified using dot notation * @param {any} expectedSchema a JSON schema object which should match the JSON body or the JSON body's subelement. For more details on format see the JSON schema website */ schema(subelement: string, expectedSchema: any); /** * Checks the schema of the returned JSON object against a provided JSON Schema. This assertion utilizes the brilliant tv4 library. An optional dot notation argument allows a subelement of the JSON object to checked against a JSON schema. Amoungst others, this can confirm types, array lengths, required fields, min and max of numbers and string lengths. For more examples see the test/assertions/schema.js tests. * * @param {any} expectedSchema a JSON schema object which should match the JSON body or the JSON body's subelement. For more details on format see the JSON schema website */ schema(expectedSchema: any); /** * Either checks that a cookie exists or ensures the cookie matches a given value * * @param {string} name checks a cookie with this name exists * @param {[string | RegExp]} value if specified, checks the cookie matches the given string or regular expression */ cookie(name: string, value?: string | RegExp); } } } /// /** * Citra assertions * */ declare global { namespace Chai { interface CitraTypeComparisons { /** * confirmAction * asserts if actions contains a action with name confirm */ confirmAction(): Assertion; /** * completeAction * asserts if action is complete */ completeAction(): Assertion; /** * tasklink property. * asserts if a href is available */ tasklink: Assertion; /** * asserts if a href is available */ href(): Assertion; state(string): Assertion; } interface CitraAssertions { // can Language Chain can: LanguageChains; // processStatus assertions applicable: Assertion; needed: Assertion; not_needed: Assertion; needed_unknown: Assertion; completed: Assertion; } interface TypeComparison extends CitraTypeComparisons {} interface Assertion extends CitraAssertions {} } } //# sourceMappingURL=citra.d.ts.map