diff --git a/types/jasmine-data-provider/index.d.ts b/types/jasmine-data-provider/index.d.ts index 65ae1af270..26f96be2d0 100644 --- a/types/jasmine-data-provider/index.d.ts +++ b/types/jasmine-data-provider/index.d.ts @@ -2,13 +2,15 @@ // Project: https://github.com/MortalFlesh/jasmine-data-provider // Definitions by: Tomek Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.8 +declare function using(values: using.ValueType, func: (...data: Array>) => void): void; declare function using(values: using.ValueType, func: (data: T) => void): void; -declare function using(values: using.ValueType, func: (data: T[K], description: K) => void): void; +declare function using(values: using.ValueType>, func: (data: T, description: string) => void): void; declare namespace using { type ValueType = T | (() => T); + type ArrayFuncArgType = T extends Array ? U : never; } export = using; diff --git a/types/jasmine-data-provider/jasmine-data-provider-tests.ts b/types/jasmine-data-provider/jasmine-data-provider-tests.ts index bccc74f863..361f1b49c0 100644 --- a/types/jasmine-data-provider/jasmine-data-provider-tests.ts +++ b/types/jasmine-data-provider/jasmine-data-provider-tests.ts @@ -46,3 +46,40 @@ describe('My fantastic test', () => { }); }); }); + +// undocumented behaviour + +describe(`Ugh, I don't know if this one works`, () => { + using([[6, 3, 9], [8, 1, 10]], (a, b, expected) => { + it('should calc with operator +', () => { + const result = calculator.calc(a, b, '+'); + + expect(result).toEqual(expected); + }); + }); +}); + +// TypeScript-specific tests + +describe('My awesome test with declared types!', () => { + interface TestType { + value: number; + expected: number; + } + + using([{ value: 2, expected: 4 }], (data) => { + it('should calc with operator ^2', () => { + const result = calculator.calc(data.value, '^2'); + + expect(result).toEqual(data.expected); + }); + }); + + using({ desc: { value: 2, expected: 4 } }, (data, description) => { + it(description, () => { + const result = calculator.calc(data.value, '^2'); + + expect(result).toEqual(data.expected); + }); + }); +});