Skip to content

Commit 523ee99

Browse files
fix: mocks with vitest v4
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent c43c9ad commit 523ee99

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

test/mocks/davCollection.mock.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
import { vi } from "vitest";
77

8-
const DavCollection = vi.fn()
9-
10-
DavCollection.prototype.findAll = vi.fn();
11-
DavCollection.prototype.findAllByFilter = vi.fn();
12-
DavCollection.prototype.find = vi.fn();
13-
DavCollection.prototype.createCollection = vi.fn();
14-
DavCollection.prototype.createObject = vi.fn();
15-
DavCollection.prototype.update = vi.fn();
16-
DavCollection.prototype.delete = vi.fn();
17-
DavCollection.prototype.isReadable = vi.fn();
18-
DavCollection.prototype.isWriteable = vi.fn();
19-
DavCollection.prototype.isSameCollectionTypeAs = vi.fn();
8+
const DavCollection = vi.fn().mockImplementation(function() {
9+
this.findAll = vi.fn();
10+
this.findAllByFilter = vi.fn();
11+
this.find = vi.fn();
12+
this.createCollection = vi.fn();
13+
this.createObject = vi.fn();
14+
this.update = vi.fn();
15+
this.delete = vi.fn();
16+
this.isReadable = vi.fn();
17+
this.isWriteable = vi.fn();
18+
this.isSameCollectionTypeAs = vi.fn();
19+
});
2020

2121
export { DavCollection };

test/mocks/request.mock.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
import { vi } from "vitest";
77

8-
const Request = vi.fn()
9-
10-
Request.prototype.propFind = vi.fn();
11-
Request.prototype.put = vi.fn();
12-
Request.prototype.post = vi.fn();
13-
Request.prototype.delete = vi.fn();
14-
Request.prototype.move = vi.fn();
15-
Request.prototype.copy = vi.fn();
16-
Request.prototype.report = vi.fn();
17-
Request.prototype.pathname = vi.fn();
18-
Request.prototype.propPatch = vi.fn();
19-
Request.prototype.mkCol = vi.fn();
8+
const Request = vi.fn().mockImplementation(function() {
9+
this.propFind = vi.fn();
10+
this.put = vi.fn();
11+
this.post = vi.fn();
12+
this.delete = vi.fn();
13+
this.move = vi.fn();
14+
this.copy = vi.fn();
15+
this.report = vi.fn();
16+
this.pathname = vi.fn();
17+
this.propPatch = vi.fn();
18+
this.mkCol = vi.fn();
19+
});
2020

2121
export default Request

0 commit comments

Comments
 (0)