mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[jasmine-data-provider] definitions for undocumented behaviour (#29835)
* improve type defs * undocumented types * change type * satisfy the linter
This commit is contained in:
parent
724810601f
commit
cc7d8d21ae
6
types/jasmine-data-provider/index.d.ts
vendored
6
types/jasmine-data-provider/index.d.ts
vendored
@ -2,13 +2,15 @@
|
||||
// Project: https://github.com/MortalFlesh/jasmine-data-provider
|
||||
// Definitions by: Tomek Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
declare function using<T extends any[]>(values: using.ValueType<T[]>, func: (...data: Array<using.ArrayFuncArgType<T>>) => void): void;
|
||||
declare function using<T>(values: using.ValueType<T[]>, func: (data: T) => void): void;
|
||||
declare function using<T, K extends keyof T>(values: using.ValueType<T>, func: (data: T[K], description: K) => void): void;
|
||||
declare function using<T>(values: using.ValueType<Record<string, T>>, func: (data: T, description: string) => void): void;
|
||||
|
||||
declare namespace using {
|
||||
type ValueType<T> = T | (() => T);
|
||||
type ArrayFuncArgType<T> = T extends Array<infer U> ? U : never;
|
||||
}
|
||||
|
||||
export = using;
|
||||
|
||||
@ -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<TestType>([{ value: 2, expected: 4 }], (data) => {
|
||||
it('should calc with operator ^2', () => {
|
||||
const result = calculator.calc(data.value, '^2');
|
||||
|
||||
expect(result).toEqual(data.expected);
|
||||
});
|
||||
});
|
||||
|
||||
using<TestType>({ desc: { value: 2, expected: 4 } }, (data, description) => {
|
||||
it(description, () => {
|
||||
const result = calculator.calc(data.value, '^2');
|
||||
|
||||
expect(result).toEqual(data.expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user