diff --git a/easy-xapi-supertest/easy-xapi-supertest-tests.ts b/easy-xapi-supertest/easy-xapi-supertest-tests.ts new file mode 100644 index 000000000..5b43ce061 --- /dev/null +++ b/easy-xapi-supertest/easy-xapi-supertest-tests.ts @@ -0,0 +1,27 @@ +/** + * Created by karl on 14/07/15. + */ + +/// +/// + +import express = require('express'); +import eSupertest = require('easy-xapi-supertest'); + +var app = express(); + +var getAgent = eSupertest.getAgentFactory(app); + +var agent = getAgent({ + user: 'Jack', + role: 'user' +}); + +var getAgent2 = eSupertest.getAgentFactory(app, function (user:string, role?:string) { + return { + user: user, + role: role || 'user' + } +}); + +var agent = getAgent2('Jack'); diff --git a/easy-xapi-supertest/easy-xapi-supertest.d.ts b/easy-xapi-supertest/easy-xapi-supertest.d.ts new file mode 100644 index 000000000..4ea936976 --- /dev/null +++ b/easy-xapi-supertest/easy-xapi-supertest.d.ts @@ -0,0 +1,29 @@ +// Type definitions for easy-x-headers +// Project: https://github.com/DeadAlready/easy-x-headers +// Definitions by: Karl Düüna +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "easy-xapi-supertest" { + import express = require('express'); + + export interface BodyAgent { + send(data: Object): any; + attach(arg1: any, arg2?: any): any; + } + + export interface Agent { + get(url:string): any; + delete(url:string): any; + post(url:string): BodyAgent; + patch(url:string): BodyAgent; + put(url:string): BodyAgent; + } + + interface getAgent { + (...args:any[]): Agent + } + + export function getAgentFactory(app: express.Application, transform?: Function): getAgent; +}