From 7aaa5e283440067826b348015138a87f84cefb93 Mon Sep 17 00:00:00 2001 From: Tim Brust Date: Wed, 21 Jun 2017 10:38:43 +0200 Subject: [PATCH] feat: add testingbot-api typings --- types/testingbot-api/index.d.ts | 68 ++++++++++++++++++++ types/testingbot-api/testingbot-api-tests.ts | 21 ++++++ types/testingbot-api/tsconfig.json | 22 +++++++ types/testingbot-api/tslint.json | 1 + 4 files changed, 112 insertions(+) create mode 100644 types/testingbot-api/index.d.ts create mode 100644 types/testingbot-api/testingbot-api-tests.ts create mode 100644 types/testingbot-api/tsconfig.json create mode 100644 types/testingbot-api/tslint.json diff --git a/types/testingbot-api/index.d.ts b/types/testingbot-api/index.d.ts new file mode 100644 index 0000000000..da320b740a --- /dev/null +++ b/types/testingbot-api/index.d.ts @@ -0,0 +1,68 @@ +// Type definitions for testingbot-api 1.0 +// Project: https://github.com/testingbot/testingbot-api +// Definitions by: Tim Brust +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace TestingBot { + type BrowserType = 'webdriver' | 'rc'; + type TestSuccess = true | false | 0 | 1; + + interface TestingBotOptions { + api_key?: string; + api_secret?: string; + } + + interface UserInfo { + first_name?: string; + last_name?: string; + email?: string; + } + + interface TestData { + 'test[success]'?: TestSuccess; + 'test[status_message]'?: string; + 'test[name]'?: string; + 'test[extra]'?: string; + build?: string; + groups?: string; + } + + interface TestLabData { + 'test[url]'?: string; + 'test[name]'?: string; + 'test[cron]'?: string; + 'test[enabled]'?: boolean; + } + + interface TestingBot { + getTestDetails(testID: string, callback?: () => any): void; + + getBrowsers(callback?: () => any, type?: BrowserType): void; + + getLabTestDetails(testID: string, callback?: () => any): void; + + getTunnel(callback?: () => any): void; + + getUserInfo(callback?: () => any): void; + + getTests(callback?: () => any, offset?: number, limit?: number): void; + + getLabTests(callback?: () => any, offset?: number, limit?: number): void; + + updateUserInfo(data: UserInfo, callback?: () => any): void; + + updateTest(data: TestData, testID: string, callback?: () => any): void; + + updateLabTest(data: TestLabData, testID: string, callback?: () => any): void; + + deleteTest(testID: string, callback?: () => any): void; + + deleteLabTest(testID: string, callback?: () => any): void; + } +} + +declare const TestingBot: { + new (options?: TestingBot.TestingBotOptions): TestingBot.TestingBot; +}; + +export = TestingBot; diff --git a/types/testingbot-api/testingbot-api-tests.ts b/types/testingbot-api/testingbot-api-tests.ts new file mode 100644 index 0000000000..c12b67f64b --- /dev/null +++ b/types/testingbot-api/testingbot-api-tests.ts @@ -0,0 +1,21 @@ +import * as TestingBot from 'testingbot-api'; + +const sessionId = '123'; + +const tb = new TestingBot({ + api_key: 'api-key', + api_secret: 'api-secret' +}); + +function noop() { } + +tb.updateUserInfo({ + email: 'new-email' +}, noop); + +tb.getBrowsers(noop, 'webdriver'); + +tb.updateTest({ + 'test[name]': 'test', + build: '01' +}, sessionId); diff --git a/types/testingbot-api/tsconfig.json b/types/testingbot-api/tsconfig.json new file mode 100644 index 0000000000..75211dbf62 --- /dev/null +++ b/types/testingbot-api/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "testingbot-api-tests.ts" + ] +} diff --git a/types/testingbot-api/tslint.json b/types/testingbot-api/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/testingbot-api/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }