GeezerVison is showing github.com — test_runner: fix invalid timer call · nodejs/node@ba57c24
File treeExpand file treeCollapse file tree Open diff view settings lib/internal/test_runner/mock
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/test_runner/mock/mock_timers.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -371,7 +371,7 @@ class MockTimers { | 371 | 371 | ObjectDefineProperty( | 372 | 372 | nodeTimers, | 373 | 373 | 'setTimeout', | 374 | | - this.#realSetTimeout, | | 374 | + this.#realTimersSetTimeout, | 375 | 375 | ); | 376 | 376 | ObjectDefineProperty( | 377 | 377 | nodeTimers, | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-mock-timers.js +24-15Lines changed: 24 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,8 +46,7 @@ describe('Mock Timers Test Suite', () => { | 46 | 46 | code: 'ERR_INVALID_ARG_VALUE', | 47 | 47 | }); | 48 | 48 | }); | 49 | | - | 50 | | - it('should check that propertyDescriptor gets back after reseting timers', (t) => { | | 49 | + it('should check that propertyDescriptor gets back after resetting timers', (t) => { | 51 | 50 | const getDescriptor = (ctx, fn) => Object.getOwnPropertyDescriptor(ctx, fn); | 52 | 51 | const getCurrentTimersDescriptors = () => { | 53 | 52 | const timers = [ | @@ -71,26 +70,36 @@ describe('Mock Timers Test Suite', () => { | 71 | 70 | nodeTimersPromises: nodeTimersPromisesDescriptors, | 72 | 71 | }; | 73 | 72 | }; | 74 | | - const before = getCurrentTimersDescriptors(); | | 73 | + | | 74 | + const originalDescriptors = getCurrentTimersDescriptors(); | | 75 | + | 75 | 76 | t.mock.timers.enable(); | 76 | 77 | const during = getCurrentTimersDescriptors(); | 77 | 78 | t.mock.timers.reset(); | 78 | 79 | const after = getCurrentTimersDescriptors(); | 79 | 80 |
| 80 | | - assert.deepStrictEqual( | 81 | | - before, | 82 | | - after, | 83 | | - ); | | 81 | + for (const env in originalDescriptors) { | | 82 | + for (const prop in originalDescriptors[env]) { | | 83 | + const originalDescriptor = originalDescriptors[env][prop]; | | 84 | + const afterDescriptor = after[env][prop]; | 84 | 85 |
| 85 | | - assert.notDeepStrictEqual( | 86 | | - before, | 87 | | - during, | 88 | | - ); | | 86 | + assert.deepStrictEqual( | | 87 | + originalDescriptor, | | 88 | + afterDescriptor, | | 89 | + ); | 89 | 90 |
| 90 | | - assert.notDeepStrictEqual( | 91 | | - during, | 92 | | - after, | 93 | | - ); | | 91 | + assert.notDeepStrictEqual( | | 92 | + originalDescriptor, | | 93 | + during[env][prop], | | 94 | + ); | | 95 | + | | 96 | + assert.notDeepStrictEqual( | | 97 | + during[env][prop], | | 98 | + after[env][prop], | | 99 | + ); | | 100 | + | | 101 | + } | | 102 | + } | 94 | 103 | }); | 95 | 104 |
| 96 | 105 | it('should reset all timers when calling .reset function', (t) => { | |
|