Visitar URL original
fix: align restoreObject docs test with idempotent behavior (#2745) · sinonjs/sinon@40c4caa · GitHub
Skip to content

Commit 40c4caa

Browse files
authored
fix: align restoreObject docs test with idempotent behavior (#2745)
restoreObject was made idempotent in #2737 — it no longer throws for objects with no restorable methods. Updates the docs page and its corresponding test to reflect this.
1 parent 5ccb7fd commit 40c4caa

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

‎docs/concepts/utils.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Restores all methods of an object and returns the restored object.
2323

2424
<<< ../.vitepress/tests/docs/utils-2.test.js
2525

26-
Throws an error if the object contains no restorable methods (spies, stubs, etc).
26+
Does nothing if the object contains no restorable methods (spies, stubs, etc).
2727

2828
<<< ../.vitepress/tests/docs/utils-3.test.js
2929

30-
Throws an error if the object contains no restorable methods (spies, stubs, etc).
30+
Does nothing if the object contains no restorable methods (spies, stubs, etc).

‎docs/tests/docs/utils-3.test.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import t from "tap";
22
import sinon from "sinon";
33

4-
t.test("restoreObject throws when object has no restorable methods", (t) => {
4+
t.test("restoreObject is a no-op when object has no restorable methods", (t) => {
55
const emptyObj = {};
66

7-
// Verify it throws an error
8-
t.throws(
7+
t.doesNotThrow(
98
() => sinon.restoreObject(emptyObj),
10-
/no methods/i,
11-
"should throw error about no methods to restore"
9+
"should be a no-op when object has no restorable methods"
1210
);
1311

1412
t.end();

0 commit comments

Comments
 (0)