Skip to content

Commit

Permalink
jasmine-data_driven_tests: Use generics for more specific typing (Def…
Browse files Browse the repository at this point in the history
…initelyTyped#14820)

* jasmine-data_driven_tests: Use generics for more specific typing

Also remove the dependency on "jasmine".

* Use "jasmine" dependency and add overloads for bigger tuples
  • Loading branch information
Andy authored Feb 27, 2017
1 parent 5a239ff commit 2b11761
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
36 changes: 34 additions & 2 deletions jasmine-data_driven_tests/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
// Project: https://github.com/gburghardt/jasmine-data_driven_tests
// Definitions by: Anthony MacKinnon <https://github.com/AnthonyMacKinnon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1

declare function all(description: string, dataset: any[], assertion: (...args: any[]) => void): void;
declare function xall(description: string, dataset: any[], assertion: (...args: any[]) => void): void;
declare var all: JasmineDataDrivenTest;
declare var xall: JasmineDataDrivenTest;

interface JasmineDataDrivenTest {
<T, U, V, W, X, Y, Z>(
description: string,
dataset: Array<[T, U, V, W, X, Y, Z]>,
assertion: (arg0: T, arg1: U, arg2: V, arg3: W, arg4: X, arg5: Y, arg6: Z, done: () => void) => void): void;
<T, U, V, W, X, Y>(
description: string,
dataset: Array<[T, U, V, W, X, Y]>,
assertion: (arg0: T, arg1: U, arg2: V, arg3: W, arg4: X, arg5: Y, done: () => void) => void): void;
<T, U, V, W, X>(
description: string,
dataset: Array<[T, U, V, W, X]>,
assertion: (arg0: T, arg1: U, arg2: V, arg3: W, arg4: X, done: () => void) => void): void;
<T, U, V, W>(
description: string,
dataset: Array<[T, U, V, W]>,
assertion: (arg0: T, arg1: U, arg2: V, arg3: W, done: () => void) => void): void;
<T, U, V>(
description: string,
dataset: Array<[T, U, V]>,
assertion: (arg0: T, arg1: U, arg2: V, done: () => void) => void): void;
<T, U>(
description: string,
dataset: Array<[T, U]>,
assertion: (arg0: T, arg1: U, done: () => void) => void): void;
<T>(
description: string,
dataset: T[],
assertion: (value: T, done: () => void) => void): void;
}
11 changes: 5 additions & 6 deletions jasmine-data_driven_tests/jasmine-data_driven_tests-tests.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

/// <reference types="jasmine" />

all("A data driven test is a suite with multiple specs",
['a', 'b', 'c'],
(value: string) => {
value => {
expect(value).not.toBe('d');
}
);
Expand All @@ -13,7 +12,7 @@ all("A data driven test can have many arguments",
[1, 2, 3],
[2, 4, 6]
],
(a: number, b: number, c: number) => {
(a, b, c) => {
expect(c - (a + b)).toBe(0);
}
);
Expand All @@ -23,7 +22,7 @@ all("A data driven test can be asynchronous",
[3, 1],
[5, 2]
],
(a: number, b: number, done: () => void) => {
(a, b, done) => {
setTimeout(() => {
expect(a - b > 0).toBe(true);
done();
Expand All @@ -33,7 +32,7 @@ all("A data driven test can be asynchronous",

xall("A data driven test can be pending",
[1, 2, 3],
(value: number) => {
value => {
expect(value < 4).toBe(true);
}
);
Expand All @@ -47,7 +46,7 @@ describe("A suite", () => {

all("can contain data driven tests",
[1, 2, 3],
(b: number) => {
b => {
expect(a - b > 0).toBe(true);
}
);
Expand Down

0 comments on commit 2b11761

Please sign in to comment.