mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
jasmine: Add definitionAdded static falsy, truthy, empty, notEmpty (#37428)
* Add definitionAdded static falsy, truthy, empty, notEmpty * Fix semicolon * Remove duplicate test
This commit is contained in:
parent
cbcae98e13
commit
bbee6fcddf
40
types/jasmine/index.d.ts
vendored
40
types/jasmine/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for Jasmine 3.3
|
||||
// Type definitions for Jasmine 3.4
|
||||
// Project: http://jasmine.github.io
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov>
|
||||
// Theodore Brown <https://github.com/theodorejb>
|
||||
@ -13,6 +13,7 @@
|
||||
// Peter Safranek <https://github.com/pe8ter>
|
||||
// Moshe Kolodny <https://github.com/kolodny>
|
||||
// Stephen Farrar <https://github.com/stephenfarrar>
|
||||
// Mochamad Arfin <https://github.com/ndunks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
||||
@ -199,6 +200,30 @@ declare namespace jasmine {
|
||||
|
||||
function anything(): Any;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is `true` or anything truthy.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function truthy(): Truthy;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function falsy(): Falsy;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is empty.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function empty(): Empty;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is not empty.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function notEmpty(): NotEmpty;
|
||||
|
||||
function arrayContaining<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
||||
function arrayWithExactContents<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
||||
function objectContaining<T>(sample: Partial<T>): ObjectContaining<T>;
|
||||
@ -230,10 +255,15 @@ declare namespace jasmine {
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface AsymmetricMatcher {
|
||||
interface AsymmetricMatcher<T extends string = string> {
|
||||
asymmetricMatch(other: any): boolean;
|
||||
jasmineToString?(): string;
|
||||
}
|
||||
jasmineToString?(): T;
|
||||
}
|
||||
|
||||
interface Truthy extends AsymmetricMatcher<'<jasmine.truthy>'> { }
|
||||
interface Falsy extends AsymmetricMatcher<'<jasmine.falsy>'> { }
|
||||
interface Empty extends AsymmetricMatcher<'<jasmine.empty>'> { }
|
||||
interface NotEmpty extends AsymmetricMatcher<'<jasmine.notEmpty>'> { }
|
||||
|
||||
// taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
|
||||
interface ArrayLike<T> {
|
||||
@ -246,7 +276,7 @@ declare namespace jasmine {
|
||||
}
|
||||
|
||||
interface ObjectContaining<T> {
|
||||
new?(sample: Partial<T>): Partial<T>;
|
||||
new?(sample: {[K in keyof T]?: any}): {[K in keyof T]?: any};
|
||||
|
||||
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
||||
jasmineToString?(): string;
|
||||
|
||||
@ -1317,6 +1317,49 @@ describe("createSpyObj", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Static Matcher Test', function() {
|
||||
it('Falsy', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.falsy(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('Truthy', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.truthy(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('Empty', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.empty(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('NotEmpty', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.notEmpty(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('Partial should OK', () => {
|
||||
expect({ value: null, label: 'abcd' }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.anything(),
|
||||
})
|
||||
);
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: 'any value should ok',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
(() => {
|
||||
// from boot.js
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
38
types/jasmine/ts3.1/index.d.ts
vendored
38
types/jasmine/ts3.1/index.d.ts
vendored
@ -11,6 +11,7 @@
|
||||
// Peter Safranek <https://github.com/pe8ter>
|
||||
// Moshe Kolodny <https://github.com/kolodny>
|
||||
// Stephen Farrar <https://github.com/stephenfarrar>
|
||||
// Mochamad Arfin <https://github.com/ndunks>
|
||||
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
|
||||
|
||||
type ImplementationCallback = (() => Promise<any>) | ((done: DoneFn) => void);
|
||||
@ -208,6 +209,30 @@ declare namespace jasmine {
|
||||
|
||||
function anything(): Any;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is `true` or anything truthy.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function truthy(): Truthy;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is `null`, `undefined`, `0`, `false` or anything falsey.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function falsy(): Falsy;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is empty.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function empty(): Empty;
|
||||
|
||||
/**
|
||||
* That will succeed if the actual value being compared is not empty.
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function notEmpty(): NotEmpty;
|
||||
|
||||
function arrayContaining<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
||||
function arrayWithExactContents<T>(sample: ArrayLike<T>): ArrayContaining<T>;
|
||||
function objectContaining<T>(sample: Partial<T>): ObjectContaining<T>;
|
||||
@ -239,10 +264,15 @@ declare namespace jasmine {
|
||||
jasmineToString(): string;
|
||||
}
|
||||
|
||||
interface AsymmetricMatcher {
|
||||
interface AsymmetricMatcher<T extends string = string> {
|
||||
asymmetricMatch(other: any): boolean;
|
||||
jasmineToString?(): string;
|
||||
}
|
||||
jasmineToString?(): T;
|
||||
}
|
||||
|
||||
interface Truthy extends AsymmetricMatcher<'<jasmine.truthy>'> { }
|
||||
interface Falsy extends AsymmetricMatcher<'<jasmine.falsy>'> { }
|
||||
interface Empty extends AsymmetricMatcher<'<jasmine.empty>'> { }
|
||||
interface NotEmpty extends AsymmetricMatcher<'<jasmine.notEmpty>'> { }
|
||||
|
||||
// taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
|
||||
interface ArrayLike<T> {
|
||||
@ -255,7 +285,7 @@ declare namespace jasmine {
|
||||
}
|
||||
|
||||
interface ObjectContaining<T> {
|
||||
new?(sample: Partial<T>): Partial<T>;
|
||||
new?(sample: {[K in keyof T]?: any}): {[K in keyof T]?: any};
|
||||
|
||||
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
||||
jasmineToString?(): string;
|
||||
|
||||
@ -1398,6 +1398,49 @@ describe("createSpyObj", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Static Matcher Test', function() {
|
||||
it('Falsy', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.falsy(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('Truthy', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.truthy(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('Empty', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.empty(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('NotEmpty', () => {
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.notEmpty(),
|
||||
})
|
||||
);
|
||||
});
|
||||
it('Partial should OK', () => {
|
||||
expect({ value: null, label: 'abcd' }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: jasmine.anything(),
|
||||
})
|
||||
);
|
||||
expect({ value: null }).toEqual(
|
||||
jasmine.objectContaining({
|
||||
value: 'any value should ok',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
(() => {
|
||||
// from boot.js
|
||||
const env = jasmine.getEnv();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user