Skip to content

Commit 9c06811

Browse files
committed
chore: test case
1 parent 282d580 commit 9c06811

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

packages/ai-native/__test__/browser/chat/chat-agent.service.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ describe('ChatAgentService', () => {
1414
injector = createBrowserInjector(
1515
[],
1616
new MockInjector([
17-
{
18-
token: IChatAgentService,
19-
useClass: ChatAgentService,
20-
},
2117
{
2218
token: IChatManagerService,
2319
useValue: {
@@ -32,7 +28,7 @@ describe('ChatAgentService', () => {
3228
},
3329
]),
3430
);
35-
chatAgentService = injector.get(IChatAgentService);
31+
chatAgentService = new ChatAgentService();
3632
});
3733

3834
it('should register an agent', () => {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { JSX } from 'react';
2+
import type { BundledLanguage } from 'shiki';
3+
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
4+
import { Fragment } from 'react';
5+
import { jsx, jsxs } from 'react/jsx-runtime';
6+
import { codeToHast, codeToHtml } from 'shiki';
7+
8+
export default function Page() {
9+
return (
10+
<main>
11+
<CodeBlock lang='ts'>{['console.log("Hello")', 'console.log("World")'].join('\n')}</CodeBlock>
12+
</main>
13+
);
14+
}
15+
16+
interface Props {
17+
children: string;
18+
lang: BundledLanguage;
19+
}
20+
21+
async function CodeBlock(props: Props) {
22+
const out = await codeToHtml(props.children, {
23+
lang: props.lang,
24+
theme: 'github-dark',
25+
});
26+
27+
return toJsxRuntime(out, {
28+
Fragment,
29+
jsx,
30+
jsxs,
31+
components: {
32+
// your custom `pre` element
33+
pre: (props) => <pre data-custom-codeblock {...props} />,
34+
},
35+
}) as JSX.Element;
36+
}

0 commit comments

Comments
 (0)