Allow to use argument matchers in withArgs() (#38738)

This commit is contained in:
Alex Povar
2019-10-10 12:59:32 -07:00
committed by Armando Aguirre
parent 3190056069
commit aed6042848
3 changed files with 10 additions and 4 deletions
+3
View File
@@ -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]);
+1 -1
View File
@@ -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 & {
+6 -3
View File
@@ -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]);