From 73f53d2d62654370aef38cad46ca35f270bba5e5 Mon Sep 17 00:00:00 2001 From: Even Stensberg Date: Tue, 2 Jan 2024 17:27:17 +0100 Subject: [PATCH] tests(tsx): add tests --- index.js | 4 ++-- test/fixtures/ts/5/package.json | 5 +++++ test/fixtures/ts/5/test.ts | 15 +++++++++++++++ test/fixtures/tsx/5/data.tsx | 13 +++++++++++++ test/fixtures/tsx/5/package.json | 5 +++++ test/fixtures/tsx/5/test.tsx | 11 +++++++++++ test/index.js | 1 + 7 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/ts/5/package.json create mode 100644 test/fixtures/ts/5/test.ts create mode 100644 test/fixtures/tsx/5/data.tsx create mode 100644 test/fixtures/tsx/5/package.json create mode 100644 test/fixtures/tsx/5/test.tsx diff --git a/index.js b/index.js index 22f9ed4..2665609 100644 --- a/index.js +++ b/index.js @@ -401,7 +401,6 @@ var extensions = { ); }, }, - 'tsx/dist/esm/index.cjs', { module: '@swc/register', register: function (hook, config) { @@ -425,6 +424,7 @@ var extensions = { ); }, }, + 'tsx/dist/cjs/index.cjs', ], '.cts': ['ts-node/register'], '.tsx': [ @@ -499,7 +499,7 @@ var extensions = { ); }, }, - 'tsx/dist/esm/index.cjs', + 'tsx/dist/cjs/index.cjs', ], '.yaml': 'yaml-hook/register', '.yml': 'yaml-hook/register', diff --git a/test/fixtures/ts/5/package.json b/test/fixtures/ts/5/package.json new file mode 100644 index 0000000..a5757e8 --- /dev/null +++ b/test/fixtures/ts/5/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "tsx": "^4.7.0" + } +} diff --git a/test/fixtures/ts/5/test.ts b/test/fixtures/ts/5/test.ts new file mode 100644 index 0000000..06c3cc0 --- /dev/null +++ b/test/fixtures/ts/5/test.ts @@ -0,0 +1,15 @@ +var test = { + data: { + trueKey: true, + falseKey: false, + subKey: { + subProp: 1, + }, + }, +}; + +var main = { + default: test, +}; + +export = main; \ No newline at end of file diff --git a/test/fixtures/tsx/5/data.tsx b/test/fixtures/tsx/5/data.tsx new file mode 100644 index 0000000..e2f8fab --- /dev/null +++ b/test/fixtures/tsx/5/data.tsx @@ -0,0 +1,13 @@ +export const data: { + trueKey: boolean + falseKey: boolean + subKey: { + subProp: number + } +} = { + trueKey: true, + falseKey: false, + subKey: { + subProp: 1 + } +} diff --git a/test/fixtures/tsx/5/package.json b/test/fixtures/tsx/5/package.json new file mode 100644 index 0000000..a5757e8 --- /dev/null +++ b/test/fixtures/tsx/5/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "tsx": "^4.7.0" + } +} diff --git a/test/fixtures/tsx/5/test.tsx b/test/fixtures/tsx/5/test.tsx new file mode 100644 index 0000000..da694b8 --- /dev/null +++ b/test/fixtures/tsx/5/test.tsx @@ -0,0 +1,11 @@ +/** @jsx jsx */ + +import { data } from './data' + +const Component = (props: object) => ({ data: props }) + +function jsx (element: typeof Component, props: object) { + return element(props) +} + +export default diff --git a/test/index.js b/test/index.js index 1f9ca83..e7c0d49 100644 --- a/test/index.js +++ b/test/index.js @@ -135,6 +135,7 @@ describe('interpret.extensions', function () { this.skip(); } + // if (name === '') this.timeout(0); var expected;