From 8f60ec6b266fa0aa9b4dc742f1695af04f999dd9 Mon Sep 17 00:00:00 2001 From: Hoikan <30694822+HoikanChan@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:58:16 +0800 Subject: [PATCH] feat: test --- demos/benchmark/src/main.jsx | 119 +++++++--- demos/v2/index.html | 2 +- demos/v2/src/App.view.tsx | 76 +------ packages/inula-next/package.json | 7 +- packages/inula-next/src/index.js | 2 +- packages/inula-next/test/props.test.tsx | 140 ++++++++++++ packages/inula-next/test/rendering.test.tsx | 203 ++++++++++++++++++ packages/inula-next/test/utils.ts | 30 +++ packages/inula-next/tsconfig.json | 3 +- packages/inula-next/vitest.config.ts | 38 ++++ packages/transpiler/README.md | 31 +++ .../class-transformer/src/plugin.ts | 4 +- .../class-transformer/src/pluginProvider.ts | 117 ++++++++-- .../src/test/component-composition.test.ts | 34 +-- .../vite-plugin-inula-next/package.json | 3 +- .../vite-plugin-inula-next/src/index.ts | 20 +- 16 files changed, 681 insertions(+), 148 deletions(-) create mode 100644 packages/inula-next/test/props.test.tsx create mode 100644 packages/inula-next/test/rendering.test.tsx create mode 100644 packages/inula-next/test/utils.ts create mode 100644 packages/inula-next/vitest.config.ts diff --git a/demos/benchmark/src/main.jsx b/demos/benchmark/src/main.jsx index 033aa9ff..5d34afdc 100644 --- a/demos/benchmark/src/main.jsx +++ b/demos/benchmark/src/main.jsx @@ -1,14 +1,53 @@ import { render, View } from '@openinula/next'; - let idCounter = 1; -const adjectives = ['pretty', 'large', 'big', 'small', 'tall', 'short', 'long', 'handsome', 'plain', 'quaint', 'clean', 'elegant', 'easy', 'angry', 'crazy', 'helpful', 'mushy', 'odd', 'unsightly', 'adorable', 'important', 'inexpensive', 'cheap', 'expensive', 'fancy']; +const adjectives = [ + 'pretty', + 'large', + 'big', + 'small', + 'tall', + 'short', + 'long', + 'handsome', + 'plain', + 'quaint', + 'clean', + 'elegant', + 'easy', + 'angry', + 'crazy', + 'helpful', + 'mushy', + 'odd', + 'unsightly', + 'adorable', + 'important', + 'inexpensive', + 'cheap', + 'expensive', + 'fancy', +]; const colours = ['red', 'yellow', 'blue', 'green', 'pink', 'brown', 'purple', 'brown', 'white', 'black', 'orange']; -const nouns = ['table', 'chair', 'house', 'bbq', 'desk', 'car', 'pony', 'cookie', 'sandwich', 'burger', 'pizza', 'mouse', 'keyboard']; +const nouns = [ + 'table', + 'chair', + 'house', + 'bbq', + 'desk', + 'car', + 'pony', + 'cookie', + 'sandwich', + 'burger', + 'pizza', + 'mouse', + 'keyboard', +]; function _random(max) { - return Math.round(Math.random() * 1000) % max; + return Math.round(Math.random() * 1000) % max; } function buildData(count) { @@ -16,21 +55,23 @@ function buildData(count) { for (let i = 0; i < count; i++) { data[i] = { id: idCounter++, - label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}` + label: `${adjectives[_random(adjectives.length)]} ${colours[_random(colours.length)]} ${nouns[_random(nouns.length)]}`, }; } return data; } -function Button ({ id, text, fn }) { +function Button({ id, text, fn }) { return ( -
- +
+
); } -function App () { +function App() { let data = []; let selected = null; function run() { @@ -63,29 +104,43 @@ function App () { } return ( -
-
-

Inula-next Keyed

-
-
-
- - - - - - - -
- -
-