| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c757e3e commit b7a8f8f
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1168,7 +1168,7 @@ test('setTime does not execute timers', (context) => { | |||
| 1168 | 1168 | const assert = require('node:assert'); | |
| 1169 | 1169 | const { test } = require('node:test'); | |
| 1170 | 1170 | ||
| 1171 | - test('runs timers as setTime passes ticks', (context) => { | ||
| 1171 | + test('setTime does not execute timers', (context) => { | ||
| 1172 | 1172 | // Optionally choose what to mock | |
| 1173 | 1173 | context.mock.timers.enable({ apis: ['setTimeout', 'Date'] }); | |
| 1174 | 1174 | const fn = context.mock.fn(); | |
@@ -1180,7 +1180,10 @@ test('runs timers as setTime passes ticks', (context) => { | |||
| 1180 | 1180 | assert.strictEqual(Date.now(), 800); | |
| 1181 | 1181 | ||
| 1182 | 1182 | context.mock.timers.setTime(1200); | |
| 1183 | - // Timer is executed as the time is now reached | ||
| 1183 | + // Timer is still not executed | ||
| 1184 | + assert.strictEqual(fn.mock.callCount(), 0); | ||
| 1185 | + // Advance in time to execute the timer | ||
| 1186 | + context.mock.timers.tick(0); | ||
| 1184 | 1187 | assert.strictEqual(fn.mock.callCount(), 1); | |
| 1185 | 1188 | assert.strictEqual(Date.now(), 1200); | |
| 1186 | 1189 | }); | |
@@ -2631,8 +2634,8 @@ test('mocks a builtin module in both module systems', async (t) => { | |||
| 2631 | 2634 | // cursorTo() is an export of the original 'node:readline' module. | |
| 2632 | 2635 | assert.strictEqual(esmImpl.cursorTo, undefined); | |
| 2633 | 2636 | assert.strictEqual(cjsImpl.cursorTo, undefined); | |
| 2634 | - assert.strictEqual(esmImpl.fn(), 42); | ||
| 2635 | - assert.strictEqual(cjsImpl.fn(), 42); | ||
| 2637 | + assert.strictEqual(esmImpl.foo(), 42); | ||
| 2638 | + assert.strictEqual(cjsImpl.foo(), 42); | ||
| 2636 | 2639 | ||
| 2637 | 2640 | mock.restore(); | |
| 2638 | 2641 | ||
@@ -2642,8 +2645,8 @@ test('mocks a builtin module in both module systems', async (t) => { | |||
| 2642 | 2645 | ||
| 2643 | 2646 | assert.strictEqual(typeof esmImpl.cursorTo, 'function'); | |
| 2644 | 2647 | assert.strictEqual(typeof cjsImpl.cursorTo, 'function'); | |
| 2645 | - assert.strictEqual(esmImpl.fn, undefined); | ||
| 2646 | - assert.strictEqual(cjsImpl.fn, undefined); | ||
| 2648 | + assert.strictEqual(esmImpl.foo, undefined); | ||
| 2649 | + assert.strictEqual(cjsImpl.foo, undefined); | ||
| 2647 | 2650 | }); | |
| 2648 | 2651 | ``` | |
| 2649 | 2652 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments