diff --git a/types/baretest/baretest-tests.ts b/types/baretest/baretest-tests.ts new file mode 100644 index 0000000000..ce296d5915 --- /dev/null +++ b/types/baretest/baretest-tests.ts @@ -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 +})(); diff --git a/types/baretest/index.d.ts b/types/baretest/index.d.ts new file mode 100644 index 0000000000..80c086c79a --- /dev/null +++ b/types/baretest/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for baretest 2.0 +// Project: https://volument.com/baretest +// Definitions by: Rory O’Kane +// 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; +} + +type SyncOrAsyncVoidFunction = () => void | Promise; diff --git a/types/baretest/tsconfig.json b/types/baretest/tsconfig.json new file mode 100644 index 0000000000..9b1d46e319 --- /dev/null +++ b/types/baretest/tsconfig.json @@ -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" + ] +} diff --git a/types/baretest/tslint.json b/types/baretest/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/baretest/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }