From d1f694fa3aa5e2969689ecd782d544993a910b03 Mon Sep 17 00:00:00 2001 From: "Dmitry A. Efimenko" Date: Fri, 31 May 2019 11:33:58 -0700 Subject: [PATCH] jasmine-given: make done arg non-optional (#35842) * jasmine-given: make done arg non-optional * simplify signature * fix readability for authors * clean up parentesis --- types/jasmine-given/index.d.ts | 14 ++++---- types/jasmine-given/jasmine-given-tests.ts | 40 ++++++---------------- 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/types/jasmine-given/index.d.ts b/types/jasmine-given/index.d.ts index df2fe424a9..1275cf9738 100644 --- a/types/jasmine-given/index.d.ts +++ b/types/jasmine-given/index.d.ts @@ -1,7 +1,9 @@ // Type definitions for jasmine-given 2.6 // Project: https://github.com/searls/jasmine-given // Definitions by: Shai Reznik +// Dmitry Efimenko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /** Action method that should be called when the async work is complete */ interface DoneFn { @@ -11,9 +13,9 @@ interface DoneFn { fail: (message?: Error | string) => void; } -declare function Given(func: (done?: DoneFn) => void): void; -declare function When(func: (done?: DoneFn) => void): void; -declare function Then(func: (done?: DoneFn) => void): void; -declare function Then(label: string, func: (done?: DoneFn) => void): void; -declare function And(func: (done?: DoneFn) => void): void; -declare function Invariant(func: (done?: DoneFn) => void): void; +declare function Given(func: (done: DoneFn) => void): void; +declare function When(func: (done: DoneFn) => void): void; +declare function Then(func: (done: DoneFn) => void): void; +declare function Then(label: string, func: (done: DoneFn) => void): void; +declare function And(func: (done: DoneFn) => void): void; +declare function Invariant(func: (done: DoneFn) => void): void; diff --git a/types/jasmine-given/jasmine-given-tests.ts b/types/jasmine-given/jasmine-given-tests.ts index 10a6b824fe..0c2fd4fb67 100644 --- a/types/jasmine-given/jasmine-given-tests.ts +++ b/types/jasmine-given/jasmine-given-tests.ts @@ -11,61 +11,41 @@ And(() => { }); Invariant(() => { }); Given((done) => { - if (done) { - done(); - } + done(); }); When((done) => { - if (done) { - done(); - } + done(); }); Then('expected condition 2', (done) => { - if (done) { - done(); - } + done(); }); And((done) => { - if (done) { - done(); - } + done(); }); Invariant((done) => { - if (done) { - done(); - } + done(); }); Given((done) => { - if (done) { - done.fail(); - } + done.fail(); }); When((done) => { - if (done) { - done.fail(); - } + done.fail(); }); Then('expected condition 2', (done) => { - if (done) { - done.fail(); - } + done.fail(); }); And((done) => { - if (done) { - done.fail(); - } + done.fail(); }); Invariant((done) => { - if (done) { - done.fail(); - } + done.fail(); });