|
1 | 1 | import {Task, Tasks} from './Tasks.js' |
2 | 2 | import {getLastFrameAfterUnmount, render} from '../../testing/ui.js' |
3 | | -import {unstyled} from '../../../../public/node/output.js' |
| 3 | +import {unstyled, TokenizedString} from '../../../../public/node/output.js' |
4 | 4 | import {AbortController} from '../../../../public/node/abort.js' |
5 | 5 | import {Stdout} from '../../ui.js' |
6 | 6 | import React from 'react' |
@@ -392,6 +392,31 @@ describe('Tasks', () => { |
392 | 392 | expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toEqual('') |
393 | 393 | await expect(promise).resolves.toEqual(undefined) |
394 | 394 | }) |
| 395 | + |
| 396 | + test('supports TokenizedString as title', async () => { |
| 397 | + // Given |
| 398 | + const firstTaskFunction = vi.fn(async () => {}) |
| 399 | + const secondTaskFunction = vi.fn(async () => {}) |
| 400 | + |
| 401 | + const firstTask: Task = { |
| 402 | + title: new TokenizedString('tokenized task 1'), |
| 403 | + task: firstTaskFunction, |
| 404 | + } |
| 405 | + |
| 406 | + const secondTask: Task = { |
| 407 | + title: 'string task 2', |
| 408 | + task: secondTaskFunction, |
| 409 | + } |
| 410 | + |
| 411 | + // When |
| 412 | + const renderInstance = render(<Tasks tasks={[firstTask, secondTask]} silent={false} />) |
| 413 | + await renderInstance.waitUntilExit() |
| 414 | + |
| 415 | + // Then |
| 416 | + expect(getLastFrameAfterUnmount(renderInstance)).toMatchInlineSnapshot('""') |
| 417 | + expect(firstTaskFunction).toHaveBeenCalled() |
| 418 | + expect(secondTaskFunction).toHaveBeenCalled() |
| 419 | + }) |
395 | 420 | }) |
396 | 421 |
|
397 | 422 | async function taskHasRendered() { |
|
0 commit comments