mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Allow to use argument matchers in withArgs() (#38738)
This commit is contained in:
committed by
Armando Aguirre
parent
3190056069
commit
aed6042848
@@ -998,6 +998,7 @@ describe("jasmine.objectContaining", () => {
|
||||
describe("when used with a spy", () => {
|
||||
it("is useful for comparing arguments", () => {
|
||||
const callback = jasmine.createSpy('callback');
|
||||
callback.withArgs(jasmine.objectContaining({ bar: "foo" })).and.returnValue(42);
|
||||
|
||||
callback({
|
||||
bar: "baz"
|
||||
@@ -1040,6 +1041,7 @@ describe("jasmine.arrayContaining", () => {
|
||||
describe("when used with a spy", () => {
|
||||
it("is useful when comparing arguments", () => {
|
||||
const callback = jasmine.createSpy('callback');
|
||||
callback.withArgs(jasmine.arrayContaining([1, 2])).and.returnValue(42);
|
||||
|
||||
callback([1, 2, 3, 4]);
|
||||
|
||||
@@ -1067,6 +1069,7 @@ describe("jasmine.arrayWithExactContents", () => {
|
||||
describe("when used with a spy", () => {
|
||||
it("is useful when comparing arguments", () => {
|
||||
const callback = jasmine.createSpy('callback');
|
||||
callback.withArgs(jasmine.arrayWithExactContents([1, 2])).and.returnValue(42);
|
||||
|
||||
callback([1, 2, 3, 4]);
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -825,7 +825,7 @@ declare namespace jasmine {
|
||||
|
||||
and: SpyAnd<Fn>;
|
||||
calls: Calls<Fn>;
|
||||
withArgs(...args: Parameters<Fn>): Spy<Fn>;
|
||||
withArgs(...args: MatchableArgs<Fn>): Spy<Fn>;
|
||||
}
|
||||
|
||||
type SpyObj<T> = T & {
|
||||
|
||||
@@ -997,7 +997,8 @@ describe("jasmine.objectContaining", () => {
|
||||
|
||||
describe("when used with a spy", () => {
|
||||
it("is useful for comparing arguments", () => {
|
||||
const callback = jasmine.createSpy<(arg: { bar: string }) => void>('callback');
|
||||
const callback = jasmine.createSpy<(arg: { bar: string }) => number>('callback');
|
||||
callback.withArgs(jasmine.objectContaining({ bar: "foo" })).and.returnValue(42);
|
||||
|
||||
callback({
|
||||
bar: "baz"
|
||||
@@ -1039,7 +1040,8 @@ describe("jasmine.arrayContaining", () => {
|
||||
|
||||
describe("when used with a spy", () => {
|
||||
it("is useful when comparing arguments", () => {
|
||||
const callback = jasmine.createSpy<(numbers: number[]) => void>('callback');
|
||||
const callback = jasmine.createSpy<(numbers: number[]) => number>('callback');
|
||||
callback.withArgs(jasmine.arrayContaining([1, 2])).and.returnValue(42);
|
||||
|
||||
callback([1, 2, 3, 4]);
|
||||
|
||||
@@ -1066,7 +1068,8 @@ describe("jasmine.arrayWithExactContents", () => {
|
||||
|
||||
describe("when used with a spy", () => {
|
||||
it("is useful when comparing arguments", () => {
|
||||
const callback = jasmine.createSpy<(arg: number[]) => void>('callback');
|
||||
const callback = jasmine.createSpy<(arg: number[]) => number>('callback');
|
||||
callback.withArgs(jasmine.arrayWithExactContents([1, 2])).and.returnValue(42);
|
||||
|
||||
callback([1, 2, 3, 4]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user