mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
adding Frisby v0.8.5 typings
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
//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
|
||||
})
|
||||
// 'afterJSON' automatically parses response body as JSON and passes it as an argument
|
||||
.afterJSON(function(user) {
|
||||
// You can use any normal jasmine-style assertions here
|
||||
expect(1+1).toEqual(2);
|
||||
|
||||
// Use data from previous result in next test
|
||||
frisby.create('Update user')
|
||||
.put(URL_AUTH + '/users/' + user.id + '.json', {tags: ['jasmine', 'bdd']})
|
||||
.expectStatus(200)
|
||||
.toss();
|
||||
})
|
||||
.toss();
|
||||
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
// 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
|
||||
|
||||
///<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 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;
|
||||
declare module "frisby" {
|
||||
export = frisby;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"frisby-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user