feat: add testingbot-api typings

This commit is contained in:
Tim Brust
2017-06-21 10:38:43 +02:00
parent a3af39ba43
commit 7aaa5e2834
4 changed files with 112 additions and 0 deletions

68
types/testingbot-api/index.d.ts vendored Normal file
View File

@@ -0,0 +1,68 @@
// Type definitions for testingbot-api 1.0
// Project: https://github.com/testingbot/testingbot-api
// Definitions by: Tim Brust <https://github.com/timbru31>
// 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;

View File

@@ -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);

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }