diff --git a/packages/inula-novdom/tests/no-vdom.test.js b/packages/inula-novdom/tests/no-vdom.test.js deleted file mode 100644 index 54de71ff..00000000 --- a/packages/inula-novdom/tests/no-vdom.test.js +++ /dev/null @@ -1,586 +0,0 @@ -/* - * Copyright (c) 2024 Huawei Technologies Co.,Ltd. - * - * openInula is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -import { computed, reactive, watch } from 'inula-reactive'; -import { template as _$template, insert as _$insert, setAttribute as _$setAttribute } from '../src/dom'; -import { createComponent as _$createComponent, render } from '../src/core'; -import { delegateEvents as _$delegateEvents, addEventListener as _$addEventListener } from '../src/event'; - -import { Show } from '../src/components/Show'; -import { For } from '../src/components/For'; - -describe('test no-vdom', () => { - it('简单的使用signal', () => { - /** - * 源码: - * const CountingComponent = () => { - * const [count, setCount] = useSignal(0); - * - * return
Count value is {count()}.
; - * }; - * - * render(() => , container); - */ - - let g_count; - - // 编译后: - const _tmpl$ = /*#__PURE__*/ _$template(`
Count value is .`); - const CountingComponent = () => { - const count = reactive(0); - g_count = count; - let View - - watch: if (count > 0) { - View.$viewValue = createView(() => {}) - } - - View = createView((() => { - const _el$ = tmp.cloneNode(true), - _el$2 = _el$.firstChild, - _el$4 = _el$2.nextSibling, - _el$3 = _el$4.nextSibling; - _$insert(_el$, count, _el$4); - return _el$; - })()); - - return View - }; - function createView(el) { - Object.defineProperty(el, '$viewValue', { - set: value => { - el.replaceWith(value); - } - }) - } - - render(() => _$createComponent(CountingComponent, {}), container); - - expect(container.querySelector('#count').innerHTML).toEqual('Count value is 0.'); - - g_count.set(c => c + 1); - - expect(container.querySelector('#count').innerHTML).toEqual('Count value is 1.'); - }); - - it('return数组,click事件', () => { - /** - * 源码: - * const CountingComponent = () => { - * const [count, setCount] = createSignal(0); - * const add = () => { - * setCount((c) => c + 1); - * } - * return <> - *
Count value is {count()}.
- *
- * ; - * }; - */ - - // 编译后: - const _tmpl$ = /*#__PURE__*/ _$template(`
Count value is .`), - _tmpl$2 = /*#__PURE__*/ _$template(`
- *
; - * }; - * - * render(() => , document.getElementById("app")); - */ - - // 编译后: - const _tmpl$ = /*#__PURE__*/ _$template(`
Count value is .`), - _tmpl$2 = /*#__PURE__*/ _$template(`
- *
; - * }; - * - * render(() => , document.getElementById("app")); - */ - - // 编译后: - const _tmpl$ = /*#__PURE__*/ _$template(`
Count value is .`), - _tmpl$2 = /*#__PURE__*/ _$template(`
- *
- *
; - * }; - * - * render(() => , document.getElementById("app")); - */ - - // 编译后: - const _tmpl$ = /*#__PURE__*/_$template(`
Count value is .`), - _tmpl$2 = /*#__PURE__*/_$template(`
- *
- * ); - * - * const Main = () => { - * const [state, setState] = createStore({data: [{id: 1, label: '111', selected: false}, {id: 2, label: '222', selected: false}], num: 2}); - * - * function run() { - * setState('data', buildData(5)); - * } - * - * return ( - *
- *
- *
- *

Horizon-reactive-novnode

- *
- *
- *
- *
- *
- *
- * - * - *
- *
- * ); - * }; - * - * render(() =>
, document.getElementById("app")); - */ - - // 编译后: - const _tmpl$ = /*#__PURE__*/_$template(``), - _tmpl$2 = /*#__PURE__*/_$template(`