mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[jasmine-3.1] Add thesaveArgumentsByValue function (#45049)
See 15f969bee7/src/core/CallTracker.js\#L117 for definition
Co-authored-by: Robert Webb <robertwebb@google.com>
This commit is contained in:
parent
c5d5f696b2
commit
2a3191d028
2
types/jasmine/index.d.ts
vendored
2
types/jasmine/index.d.ts
vendored
@ -914,6 +914,8 @@ declare namespace jasmine {
|
||||
first(): CallInfo;
|
||||
/** By chaining the spy with calls.reset(), will clears all tracking for a spy */
|
||||
reset(): void;
|
||||
/** Set this spy to do a shallow clone of arguments passed to each invocation. */
|
||||
saveArgumentsByValue(): void;
|
||||
}
|
||||
|
||||
interface CallInfo {
|
||||
|
||||
@ -794,6 +794,18 @@ describe("A spy", () => {
|
||||
|
||||
expect(foo.setBar.calls.any()).toBe(false);
|
||||
});
|
||||
|
||||
it("can save arguments by value.", () => {
|
||||
const arr = [1];
|
||||
foo.setBar.calls.saveArgumentsByValue();
|
||||
|
||||
foo.setBar(arr);
|
||||
arr.push(2);
|
||||
foo.setBar(arr);
|
||||
|
||||
expect(foo.setBar.calls.argsFor(0)[0]).toEqual([1]);
|
||||
expect(foo.setBar.calls.argsFor(1)[0]).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A spy, when created manually", () => {
|
||||
|
||||
2
types/jasmine/ts3.1/index.d.ts
vendored
2
types/jasmine/ts3.1/index.d.ts
vendored
@ -953,6 +953,8 @@ declare namespace jasmine {
|
||||
first(): CallInfo<Fn>;
|
||||
/** By chaining the spy with calls.reset(), will clears all tracking for a spy */
|
||||
reset(): void;
|
||||
/** Set this spy to do a shallow clone of arguments passed to each invocation. */
|
||||
saveArgumentsByValue(): void;
|
||||
}
|
||||
|
||||
interface CallInfo<Fn extends Func> {
|
||||
|
||||
@ -794,6 +794,18 @@ describe("A spy", () => {
|
||||
|
||||
expect(foo.setBar.calls.any()).toBe(false);
|
||||
});
|
||||
|
||||
it("can save arguments by value.", () => {
|
||||
const arr = [1];
|
||||
foo.setBar.calls.saveArgumentsByValue();
|
||||
|
||||
foo.setBar(arr);
|
||||
arr.push(2);
|
||||
foo.setBar(arr);
|
||||
|
||||
expect(foo.setBar.calls.argsFor(0)[0]).toEqual([1]);
|
||||
expect(foo.setBar.calls.argsFor(1)[0]).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A spy, when created manually", () => {
|
||||
|
||||
2
types/jasmine/v2/index.d.ts
vendored
2
types/jasmine/v2/index.d.ts
vendored
@ -669,6 +669,8 @@ declare namespace jasmine {
|
||||
first(): CallInfo;
|
||||
/** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
|
||||
reset(): void;
|
||||
/** Set this spy to do a shallow clone of arguments passed to each invocation. */
|
||||
saveArgumentsByValue(): void;
|
||||
}
|
||||
|
||||
interface CallInfo {
|
||||
|
||||
@ -610,6 +610,18 @@ describe("A spy", () => {
|
||||
|
||||
expect(foo.setBar.calls.any()).toBe(false);
|
||||
});
|
||||
|
||||
it("can save arguments by value.", () => {
|
||||
const arr = [1];
|
||||
foo.setBar.calls.saveArgumentsByValue();
|
||||
|
||||
foo.setBar(arr);
|
||||
arr.push(2);
|
||||
foo.setBar(arr);
|
||||
|
||||
expect(foo.setBar.calls.argsFor(0)[0]).toEqual([1]);
|
||||
expect(foo.setBar.calls.argsFor(1)[0]).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A spy, when created manually", () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user