From 112cd72e92b7dd3cfbaa0e7c9fadaad50f9618cd Mon Sep 17 00:00:00 2001 From: Confidential Date: Mon, 13 Nov 2017 16:55:30 +0200 Subject: [PATCH] Create definitions for gulp-jasmine@2.4 (#21431) * Create definitions for gulp-jasmine@2.4 * Fix the 'reporter' property Functionality: - Make the secondary type of the 'reporter' property in JasmineOptions ReadonlyArray instead of jasmine.CustomReporter[]. Tests: - Add some more tests Testing done: npm run lint gulp-jasmine (with and without the change to verify the tests fail properly) * Remove unnecessary empty namespace. --- types/gulp-jasmine/gulp-jasmine-tests.ts | 20 ++++++++++ types/gulp-jasmine/index.d.ts | 50 ++++++++++++++++++++++++ types/gulp-jasmine/tsconfig.json | 23 +++++++++++ types/gulp-jasmine/tslint.json | 1 + 4 files changed, 94 insertions(+) create mode 100644 types/gulp-jasmine/gulp-jasmine-tests.ts create mode 100644 types/gulp-jasmine/index.d.ts create mode 100644 types/gulp-jasmine/tsconfig.json create mode 100644 types/gulp-jasmine/tslint.json diff --git a/types/gulp-jasmine/gulp-jasmine-tests.ts b/types/gulp-jasmine/gulp-jasmine-tests.ts new file mode 100644 index 0000000000..e40f187004 --- /dev/null +++ b/types/gulp-jasmine/gulp-jasmine-tests.ts @@ -0,0 +1,20 @@ +import gulpJasmine = require("gulp-jasmine"); +import jasmine = require("jasmine"); + +const dummyReporter: jasmine.CustomReporter = {}; + +gulpJasmine(); // $ExpectType ReadWriteStream +gulpJasmine({}); +gulpJasmine({ + verbose: true, + includeStackTrace: true, + reporter: dummyReporter, + timeout: 1000, + errorOnFail: false, + config: {} +}); +gulpJasmine({ reporter: [dummyReporter, dummyReporter] }); +const readonlyDummyReporters: ReadonlyArray = [ + dummyReporter, dummyReporter +]; +gulpJasmine({ reporter: readonlyDummyReporters }); diff --git a/types/gulp-jasmine/index.d.ts b/types/gulp-jasmine/index.d.ts new file mode 100644 index 0000000000..f69fb865e6 --- /dev/null +++ b/types/gulp-jasmine/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for gulp-jasmine 2.4 +// Project: https://github.com/sindresorhus/gulp-jasmine#readme +// Definitions by: Andrey Lalev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// +/// + +interface JasmineOptions { + /** + * Display spec names in default reporter. + */ + verbose?: boolean; + + /** + * Include stack traces in failures in default reporter. + * @default false + */ + includeStackTrace?: boolean; + + /** + * Reporter(s) to use. + */ + reporter?: jasmine.CustomReporter | ReadonlyArray; + + /** + * Time to wait in milliseconds before a test automatically fails. + * @default 5000 + */ + timeout?: number; + + /** + * Stops the stream on failed tests. + * @default true + */ + errorOnFail?: boolean; + + /** + * Passes the config to Jasmine's loadConfig method. + */ + config?: object; +} + +/** + * Executes Jasmine tests. Emits a 'jasmineDone' event on success. + * @param options Optional options for the execution of the Jasmine test + */ +declare function gulpJasmine(options?: JasmineOptions): NodeJS.ReadWriteStream; +export = gulpJasmine; diff --git a/types/gulp-jasmine/tsconfig.json b/types/gulp-jasmine/tsconfig.json new file mode 100644 index 0000000000..d44751f20b --- /dev/null +++ b/types/gulp-jasmine/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "gulp-jasmine-tests.ts" + ] +} diff --git a/types/gulp-jasmine/tslint.json b/types/gulp-jasmine/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/gulp-jasmine/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }