mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-15 22:40:21 +00:00
Merge pull request #23937 from cwoodland/master
Frisby Js 2.0 Type Definition Files
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
//Example from https://www.npmjs.com/package/frisby
|
||||
import * as frisby from 'frisby';
|
||||
|
||||
import frisby = require('frisby');
|
||||
|
||||
var URL = 'http://localhost:3000/';
|
||||
var URL_AUTH = 'http://username:password@localhost:3000/';
|
||||
|
||||
frisby.globalSetup({ // globalSetup is for ALL requests
|
||||
request: {
|
||||
headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' }
|
||||
}
|
||||
frisby.globalSetup({
|
||||
request: {
|
||||
headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' }
|
||||
}
|
||||
});
|
||||
|
||||
describe('Test Suite 1', () => {
|
||||
it('should be a teapot get', (done) => {
|
||||
frisby.get(URL + '/users/3.json')
|
||||
.expect('status', 418)
|
||||
.done(done);
|
||||
});
|
||||
|
||||
it('should be a teapot post', (done) => {
|
||||
frisby.post(URL + '/users/3.json')
|
||||
.expect('status', 418)
|
||||
.done(done);
|
||||
});
|
||||
});
|
||||
|
||||
frisby.create('GET user johndoe')
|
||||
.get(URL + '/users/3.json')
|
||||
.expectStatus(200)
|
||||
.expectJSONTypes({
|
||||
id: Number,
|
||||
username: String,
|
||||
is_admin: Boolean
|
||||
})
|
||||
.expectJSON({
|
||||
id: 3,
|
||||
username: 'johndoe',
|
||||
is_admin: false
|
||||
})
|
||||
.toss();
|
||||
Vendored
+64
-66
@@ -1,75 +1,73 @@
|
||||
// Type definitions for Frisby v0.8.5
|
||||
// Type definitions for Frisby 2.0
|
||||
// Project: https://github.com/vlucas/frisby
|
||||
// Definitions by: Johnny Li <https://github.com/johnny4753>
|
||||
// Definitions by: Christopher E. Woodland <https://github.com/cwoodland>
|
||||
// Johnny Li <https://github.com/johnny4753>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
///<reference types="jasmine"/>
|
||||
/// <reference types='jasmine'/>
|
||||
|
||||
declare interface Frisby {
|
||||
globalSetup(opts: any): any;
|
||||
timeout(seconds?: number): Frisby;
|
||||
reset(): Frisby;
|
||||
not(): Frisby;
|
||||
addHeader(key: string, content: string): Frisby;
|
||||
addHeaders(headers: object): Frisby;
|
||||
removeHeader(key: string): Frisby;
|
||||
responseType(type: any): Frisby;
|
||||
// HTTP Basic Auth
|
||||
auth(username: string, password: string, digest: boolean): Frisby;
|
||||
// HTTP Request
|
||||
get(uri: string, params?: any): Frisby;
|
||||
patch(uri: string, data?: any, params?: any): Frisby;
|
||||
post(uri: string, data?: any, params?: any): Frisby;
|
||||
put(uri: string, data?: any, params?: any): Frisby;
|
||||
delete(uri: string, data?: any, params?: any): Frisby;
|
||||
head(uri: string, params?: any): Frisby;
|
||||
options(uri: string, params?: any): Frisby;
|
||||
// #region Imports
|
||||
export import nodeFetch = require('node-fetch'); // Import all definitions from node-fetch.
|
||||
//#endregion
|
||||
|
||||
expectMaxResponseTime(milliseconds: number): Frisby;
|
||||
expectStatus(statusCode: number): Frisby;
|
||||
expectHeader(header: string, content: string): Frisby;
|
||||
expectHeaderContains(header: string, content: string): Frisby;
|
||||
expectHeaderToMatch(header: string, pattern: RegExp): Frisby;
|
||||
expectBodyContains(content: string): Frisby;
|
||||
expectJSONTypes(json: any): Frisby;
|
||||
expectJSONTypes(path: string, json: any): Frisby;
|
||||
expectJSON(json: any): Frisby;
|
||||
expectJSON(path: string, json: any): Frisby;
|
||||
expectJSONSchema(path: string, jsonSchema: any): Frisby;
|
||||
expectJSONLength(length: number): Frisby;
|
||||
expectJSONLength(path: string, length: number): Frisby;
|
||||
inspectRequest(): Frisby;
|
||||
inspectResponse(): Frisby;
|
||||
inspectHeaders(): Frisby;
|
||||
inspectBody(): Frisby;
|
||||
inspectJSON(): Frisby;
|
||||
inspectStatus(): Frisby;
|
||||
retry(count: number, delayInMilliseconds?: number): Frisby;
|
||||
waits(delayInMilliseconds: number): Frisby;
|
||||
after(callback: (...args: any[]) => void): Frisby;
|
||||
afterJSON(callback: (...args: any[]) => void): Frisby;
|
||||
exceptionHandler(fn: (...args: any[]) => void): Frisby;
|
||||
toss(): void;
|
||||
|
||||
create(msg: string): Frisby;
|
||||
// #region Joi Methods
|
||||
// Reference file: https://github.com/hapijs/joi
|
||||
export import Joi = require("joi");
|
||||
// #endregion
|
||||
|
||||
// #region Frisby FrisbySpec Methods
|
||||
// Reference file: https://github.com/vlucas/frisby/blob/master/src/frisby/spec.js
|
||||
export class FrisbySpec {
|
||||
constructor(...args: any[]);
|
||||
catch(onRejected?: (error: Error) => void): FrisbySpec;
|
||||
del(url: string, params: {}): FrisbySpec;
|
||||
done(doneFn: (...args: any[]) => void): FrisbySpec;
|
||||
expect(expectName: string, ...args: any[]): FrisbySpec;
|
||||
expectNot(expectName: string): FrisbySpec;
|
||||
fetch(url: string, params: {}, options?: {}): FrisbySpec;
|
||||
fromJSON(json: {}): FrisbySpec;
|
||||
get(url: string, params: {}): FrisbySpec;
|
||||
getBaseUrl(): string | boolean;
|
||||
inspectBody(): FrisbySpec;
|
||||
inspectHeaders(): FrisbySpec;
|
||||
inspectJSON(): FrisbySpec;
|
||||
inspectLog(...args: any[]): FrisbySpec;
|
||||
inspectRequest(): FrisbySpec;
|
||||
inspectRequestHeaders(): FrisbySpec;
|
||||
inspectResponse(): FrisbySpec;
|
||||
inspectStatus(): FrisbySpec;
|
||||
patch(url: string, params: {}): FrisbySpec;
|
||||
post(url: string, params: {}): FrisbySpec;
|
||||
promise(): Promise<nodeFetch.Response>;
|
||||
put(url: string, params: {}): FrisbySpec;
|
||||
setup(opts: {}, replace: boolean): FrisbySpec;
|
||||
then(onFulfilled: {} | ((...args: any[]) => void), onRejected: (...args: any[]) => void): FrisbySpec;
|
||||
timeout(timeout: number): number;
|
||||
use(fn: (...args: any[]) => void): FrisbySpec;
|
||||
static addExpectHandler(expectName: string, expectFn: (...args: any[]) => any): void;
|
||||
static removeExpectHandler(expectName: string): void;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
declare global {
|
||||
namespace jasmine {
|
||||
interface Matchers<T> {
|
||||
toMatchOrBeNull(expected: any): boolean;
|
||||
toMatchOrBeEmpty(expected: any): boolean;
|
||||
toBeType(expected: any): boolean;
|
||||
toBeTypeOrNull(expected: any): boolean;
|
||||
toBeTypeOrUndefined(expected: any): boolean;
|
||||
toContainJson(expected: any, isNot?: boolean): boolean;
|
||||
toContainJsonTypes(expected: any, isNot?: boolean): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare const frisby: Frisby;
|
||||
export = frisby;
|
||||
// #region General Frisby Methods
|
||||
// Reference file: https://github.com/vlucas/frisby/blob/master/src/frisby.js
|
||||
|
||||
export const version: string;
|
||||
export function addExpectHandler(expectName: string, expectFn: (...args: any[]) => any): FrisbySpec;
|
||||
export function baseUrl(url: string): void;
|
||||
export function create(name: string): void;
|
||||
export function del(...args: any[]): FrisbySpec;
|
||||
export function fetch(...args: any[]): FrisbySpec;
|
||||
export function formData(): FormData;
|
||||
export function fromJSON(...args: any[]): FrisbySpec;
|
||||
export function get(...args: any[]): FrisbySpec;
|
||||
export function globalSetup(opts: {}): void;
|
||||
export function patch(...args: any[]): FrisbySpec;
|
||||
export function post(...args: any[]): FrisbySpec;
|
||||
export function put(...args: any[]): FrisbySpec;
|
||||
export function removeExpectHandler(expectName: string, expectFn: (...args: any[]) => any): FrisbySpec;
|
||||
export function setup(...args: any[]): FrisbySpec;
|
||||
export function timeout(...args: any[]): FrisbySpec;
|
||||
export function use(...args: any[]): FrisbySpec;
|
||||
// #endregion
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"lib": ["es6","dom"],
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"typeRoots": ["../"]
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"frisby-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//Example from https://www.npmjs.com/package/frisby
|
||||
import frisby = require('frisby');
|
||||
|
||||
var URL = 'http://localhost:3000/';
|
||||
var URL_AUTH = 'http://username:password@localhost:3000/';
|
||||
|
||||
frisby.globalSetup({ // globalSetup is for ALL requests
|
||||
request: {
|
||||
headers: { 'X-Auth-Token': 'fa8426a0-8eaf-4d22-8e13-7c1b16a9370c' }
|
||||
}
|
||||
});
|
||||
|
||||
frisby.create('GET user johndoe')
|
||||
.get(URL + '/users/3.json')
|
||||
.expectStatus(200)
|
||||
.expectJSONTypes({
|
||||
id: Number,
|
||||
username: String,
|
||||
is_admin: Boolean
|
||||
})
|
||||
.expectJSON({
|
||||
id: 3,
|
||||
username: 'johndoe',
|
||||
is_admin: false
|
||||
})
|
||||
.toss();
|
||||
Vendored
+75
@@ -0,0 +1,75 @@
|
||||
// Type definitions for Frisby v0.8.5
|
||||
// Project: https://github.com/vlucas/frisby
|
||||
// Definitions by: Johnny Li <https://github.com/johnny4753>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
///<reference types="jasmine"/>
|
||||
|
||||
declare interface Frisby {
|
||||
globalSetup(opts: any): any;
|
||||
timeout(seconds?: number): Frisby;
|
||||
reset(): Frisby;
|
||||
not(): Frisby;
|
||||
addHeader(key: string, content: string): Frisby;
|
||||
addHeaders(headers: object): Frisby;
|
||||
removeHeader(key: string): Frisby;
|
||||
responseType(type: any): Frisby;
|
||||
// HTTP Basic Auth
|
||||
auth(username: string, password: string, digest: boolean): Frisby;
|
||||
// HTTP Request
|
||||
get(uri: string, params?: any): Frisby;
|
||||
patch(uri: string, data?: any, params?: any): Frisby;
|
||||
post(uri: string, data?: any, params?: any): Frisby;
|
||||
put(uri: string, data?: any, params?: any): Frisby;
|
||||
delete(uri: string, data?: any, params?: any): Frisby;
|
||||
head(uri: string, params?: any): Frisby;
|
||||
options(uri: string, params?: any): Frisby;
|
||||
|
||||
expectMaxResponseTime(milliseconds: number): Frisby;
|
||||
expectStatus(statusCode: number): Frisby;
|
||||
expectHeader(header: string, content: string): Frisby;
|
||||
expectHeaderContains(header: string, content: string): Frisby;
|
||||
expectHeaderToMatch(header: string, pattern: RegExp): Frisby;
|
||||
expectBodyContains(content: string): Frisby;
|
||||
expectJSONTypes(json: any): Frisby;
|
||||
expectJSONTypes(path: string, json: any): Frisby;
|
||||
expectJSON(json: any): Frisby;
|
||||
expectJSON(path: string, json: any): Frisby;
|
||||
expectJSONSchema(path: string, jsonSchema: any): Frisby;
|
||||
expectJSONLength(length: number): Frisby;
|
||||
expectJSONLength(path: string, length: number): Frisby;
|
||||
inspectRequest(): Frisby;
|
||||
inspectResponse(): Frisby;
|
||||
inspectHeaders(): Frisby;
|
||||
inspectBody(): Frisby;
|
||||
inspectJSON(): Frisby;
|
||||
inspectStatus(): Frisby;
|
||||
retry(count: number, delayInMilliseconds?: number): Frisby;
|
||||
waits(delayInMilliseconds: number): Frisby;
|
||||
after(callback: (...args: any[]) => void): Frisby;
|
||||
afterJSON(callback: (...args: any[]) => void): Frisby;
|
||||
exceptionHandler(fn: (...args: any[]) => void): Frisby;
|
||||
toss(): void;
|
||||
|
||||
create(msg: string): Frisby;
|
||||
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace jasmine {
|
||||
interface Matchers<T> {
|
||||
toMatchOrBeNull(expected: any): boolean;
|
||||
toMatchOrBeEmpty(expected: any): boolean;
|
||||
toBeType(expected: any): boolean;
|
||||
toBeTypeOrNull(expected: any): boolean;
|
||||
toBeTypeOrUndefined(expected: any): boolean;
|
||||
toContainJson(expected: any, isNot?: boolean): boolean;
|
||||
toContainJsonTypes(expected: any, isNot?: boolean): boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare const frisby: Frisby;
|
||||
export = frisby;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../../",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"module": "commonjs",
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"paths": {
|
||||
"frisby": [
|
||||
"frisby/v0"
|
||||
]
|
||||
},
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"types": [],
|
||||
"typeRoots": [
|
||||
"../../"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"frisby-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user