mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 19:52:02 +00:00
perf(cli): memoize btw message component
This commit is contained in:
parent
bd77eef46f
commit
130d6888b4
2 changed files with 38 additions and 2 deletions
34
packages/cli/src/ui/components/messages/BtwMessage.test.tsx
Normal file
34
packages/cli/src/ui/components/messages/BtwMessage.test.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright 2025 Qwen Code
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { render } from 'ink-testing-library';
|
||||
import { BtwMessage } from './BtwMessage.js';
|
||||
|
||||
describe('BtwMessage', () => {
|
||||
it('is wrapped in React.memo to avoid unnecessary layout rerenders', () => {
|
||||
expect((BtwMessage as unknown as { $$typeof?: symbol }).$$typeof).toBe(
|
||||
Symbol.for('react.memo'),
|
||||
);
|
||||
});
|
||||
|
||||
it('renders the side question and answer', () => {
|
||||
const { lastFrame } = render(
|
||||
<BtwMessage
|
||||
btw={{
|
||||
question: 'side question',
|
||||
answer: 'side answer',
|
||||
isPending: false,
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
const output = lastFrame() ?? '';
|
||||
expect(output).toContain('/btw');
|
||||
expect(output).toContain('side question');
|
||||
expect(output).toContain('side answer');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue