diff --git a/packages/html/test/compile.test.tsx b/packages/html/test/compile.test.tsx deleted file mode 100644 index 39c5dfeed..000000000 --- a/packages/html/test/compile.test.tsx +++ /dev/null @@ -1,143 +0,0 @@ -import assert from 'node:assert'; -import test, { describe } from 'node:test'; -import Html, { compile } from '../index'; - -type Props = Html.PropsWithChildren<{ color: string }>; - -function Component({ color, children }: Props) { - return ( -
-
-
- {children} -
- ); -} - -describe('Compiled components', () => { - test('simple', () => { - const Compiled = Html.compile(Component); - - assert.equal( - 1, - '
1
' - ); - }); - - test('with children', () => { - const Compiled = Html.compile>(Component); - - assert.equal( - - <>1 - <>2 - , - '
12
' - ); - }); - - test('with props', () => { - const Compiled = Html.compile(Component); - - assert.equal( - 1, - '
1
' - ); - }); - - test('handmade component', () => { - const Compiled = Html.compile(({ color, children }: Props) => ( -
-
-
- {children} -
- )); - - assert.equal( - 1, - '
1
' - ); - }); - - test('strict', () => { - const Compiled = Html.compile(({ color, children }: Props) => ( -
-
-
- {children} -
- )); - - assert.throws( - //@ts-expect-error - Property color was not provided. - () => Compiled({}), - /Error: Property color was not provided./ - ); - - assert.throws( - //@ts-expect-error - Property color was not provided. - () => Compiled(), - /Error: The arguments object was not provided./ - ); - }); - - test('not strict', () => { - const Compiled = Html.compile( - ({ color, children }: Props) => ( -
-
-
- {children} -
- ), - false - ); - - assert.doesNotThrow( - //@ts-expect-error - Property color was not provided. - Compiled - ); - - assert.equal( - //@ts-expect-error - Property color was not provided. - , - '
' - ); - }); - - test('multiple children', () => { - const Compiled = Html.compile(({ children }) =>
{children}
); - - assert.equal( - -
1
-
2
-
, - '
1
2
' - ); - }); - - test('validations', () => { - assert.throws( - //@ts-expect-error - should complain - () => compile('not a function'), - /Error: The first argument must be a function./ - ); - - async function AsyncComponent() { - return
; - } - - assert.throws( - () => compile(AsyncComponent), - /Error: You cannot use compile\(\) with async components./ - ); - }); - - test('escapes backtick', () => { - const compiled = compile<{ prop: string }>((p) =>
` {p.prop}
); - - assert.equal(compiled({ prop: 'test' }), '
` test
'); - }); -}); diff --git a/packages/html/test/util.test.ts b/packages/html/test/util.test.ts index e1828a885..99ebb2a65 100644 --- a/packages/html/test/util.test.ts +++ b/packages/html/test/util.test.ts @@ -87,18 +87,9 @@ describe('Util', () => { test('esm and cjs usage', async () => { const Html0 = require('../index'); - const { Html: Html1 } = require('../index'); - const Html2 = require('../index').default; + const Html1 = await import('../index'); - const Html3 = await import('../index'); - const { Html: Html4 } = await import('../index'); - const Html5 = (await import('../index')).default; - - assert.deepEqual(Html0, Html); - assert.deepEqual(Html1, Html); - assert.deepEqual(Html2, Html); - assert.deepEqual(Html3, Html); - assert.deepEqual(Html4, Html); - assert.deepEqual(Html5, Html); + assert.deepStrictEqual(Html0, Html); + assert.deepStrictEqual(Html1, Html); }); });