Skip to content

Commit

Permalink
test: more check
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 28, 2023
1 parent b17c791 commit 736b61c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/core/test/mocked-class-restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ test(`mocked class method not restorable`, () => {

// restoring instance method
vi.mocked(instance1.testFn).mockRestore()
expect(vi.mocked(instance1.testFn).mock.calls).toMatchInlineSnapshot(`
[
[
"a",
],
]
`)
expect(vi.mocked(MockedE.prototype.testFn).mock.calls).toMatchInlineSnapshot(`
[
[
"a",
],
]
`)

expect(instance1.testFn('b')).toMatchInlineSnapshot(`undefined`)
expect(vi.mocked(instance1.testFn).mock.calls).toMatchInlineSnapshot(`
[
Expand All @@ -50,6 +65,9 @@ test(`mocked class method not restorable`, () => {

// restoring prototype doesn't restore instance
vi.mocked(MockedE.prototype.testFn).mockRestore()
expect(vi.mocked(instance1.testFn).mock.calls).toMatchInlineSnapshot(`[]`)
expect(vi.mocked(MockedE.prototype.testFn).mock.calls).toMatchInlineSnapshot(`[]`)

expect(instance1.testFn('c')).toMatchInlineSnapshot(`undefined`)
expect(vi.mocked(instance1.testFn).mock.calls).toMatchInlineSnapshot(`
[
Expand Down

0 comments on commit 736b61c

Please sign in to comment.