[jasmine-data-provider] adding a new definition (#29772)

* init

* strict fix

* fix strict-export-declare-modifiers

* change required ts version

* Revert "change required ts version"

This reverts commit 6ec355299606fb5b19b45126d8d4c0090f139ab0.

* apply requested changes
This commit is contained in:
Tomek Łaziuk
2018-10-16 11:01:36 -07:00
committed by Sheetal Nandi
parent 422eb6b392
commit 09a6331c19
4 changed files with 88 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for jasmine-data-provider 2.2
// 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
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 namespace using {
type ValueType<T> = T | (() => T);
}
export = using;
@@ -0,0 +1,48 @@
import * as using from 'jasmine-data-provider';
import 'jasmine';
declare const calculator: any;
describe('test subtraction with data provider - direct array', () => {
using([{ a: 5, b: 2, expected: 3 }, { a: 25, b: 26, expected: -1 }], (data) => {
it('should calc with operator -', () => {
const result = calculator.calc(data.a, data.b, '-');
expect(result).toEqual(data.expected);
});
});
});
describe('test addition with data provider - provider function', () => {
function plusProvider() {
return [
{ a: 2, b: 3, expected: 5 },
{ a: '14', b: 15, expected: 29 },
{ a: 12, b: '13', expected: 25 },
{ a: '22', b: '13', expected: 35 },
];
}
using(plusProvider, (data) => {
it('should calc with operator +', () => {
const result = calculator.calc(data.a, data.b, '+');
expect(result).toEqual(data.expected);
});
});
});
describe('My fantastic test', () => {
const objectDataProvider = {
'First one is awesome!': { a: 6, b: 3, expected: 9 },
'Second test should fail': { a: 8, b: 1, expected: 10 }
};
using(objectDataProvider, (data, description) => {
it(description, () => {
const result = calculator.calc(data.a, data.b, '+');
expect(result).toEqual(data.expected);
});
});
});
+23
View File
@@ -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",
"jasmine-data-provider-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}