From abb3f318b878ba5277212e75284ccc3412d871bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20D=C3=BC=C3=BCna?= Date: Thu, 16 Jul 2015 13:07:49 +0300 Subject: [PATCH] easy-xapi-supertest --- .../easy-xapi-supertest-tests.ts | 27 +++++++++++++++++ easy-xapi-supertest/easy-xapi-supertest.d.ts | 29 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 easy-xapi-supertest/easy-xapi-supertest-tests.ts create mode 100644 easy-xapi-supertest/easy-xapi-supertest.d.ts 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; +}