Skip to content

Commit 09a3d0d

Browse files
committed
fix mockDateToLocaleDateString
1 parent 2015651 commit 09a3d0d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/index.mock.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ export const mockFetch = () => {
5050

5151
export const mockDateToLocaleDateString = () => {
5252
global.window = Object.create(window)
53-
Object.defineProperty(window, 'Date()', {
54-
value: {
55-
toLocaleDateString: () => '2023/1/18',
56-
},
53+
class MyDate {
54+
toLocaleDateString() {
55+
return '2023/1/18'
56+
}
57+
}
58+
Object.defineProperty(window, 'Date', {
59+
value: MyDate,
5760
})
5861
}

0 commit comments

Comments
 (0)