Add types for baretest 1.0 (#43752)

* Add types for baretest 1.0

These files were based on the template written with `npx dts-gen --dt --name baretest --template module`.

* Update baretest’s types for v2.0
This commit is contained in:
Rory O’Kane 2020-04-10 20:07:18 -04:00 committed by GitHub
parent 75223873e6
commit fe4a8005c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import baretest = require('baretest');
const test = baretest('my program');
function doSetup(): void {}
function doCleanup(): void {}
function assertSomeThings(): void {}
test.before(doSetup);
test.after(doCleanup);
test('it can do things', assertSomeThings);
test.skip('it can create world peace', assertSomeThings);
test('it can do things asynchronously', async () => {
return;
});
// $ExpectError
test("you shouldn't return from a test function", () => {
return 2 + 2;
});
// $ExpectError
test("you shouldn't take parameters in a test function", (people: number) => {});
// $ExpectError
test("you shouldn't return from an async test function", async () => {
return 'data from an API under test';
});
(async () => {
const result = await test.run();
result; // $ExpectType boolean
})();

21
types/baretest/index.d.ts vendored Normal file
View File

@ -0,0 +1,21 @@
// Type definitions for baretest 2.0
// Project: https://volument.com/baretest
// Definitions by: Rory OKane <https://github.com/roryokane>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = baretest;
declare function baretest(headline: string): TesterFunctionObject;
type TesterFunctionObject = TesterFunction & TesterSubFunctions;
type TesterFunction = (name: string, fn: SyncOrAsyncVoidFunction) => void;
interface TesterSubFunctions {
only: (name: string, fn: SyncOrAsyncVoidFunction) => void;
skip: (name?: string, fn?: SyncOrAsyncVoidFunction) => void;
before: (fn: SyncOrAsyncVoidFunction) => void;
after: (fn: SyncOrAsyncVoidFunction) => void;
run: () => Promise<boolean>;
}
type SyncOrAsyncVoidFunction = () => void | Promise<void>;

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"baretest-tests.ts"
]
}

View File

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