Skip to content

Commit

Permalink
test(core): view decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
BroKun committed Dec 11, 2024
1 parent 5e9b194 commit 5af82e5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .changeset/empty-flies-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@difizen/babel-preset-mana': patch
'@difizen/mana-observable': patch
'@difizen/umi-plugin-mana': patch
'@difizen/mana-syringe': patch
'@difizen/mana-common': patch
'@difizen/mana-react': patch
'@difizen/mana-react-example': patch
'@difizen/mana-core': patch
'@difizen/mana-l10n': patch
'@difizen/mana-app': patch
'@difizen/mana-umi-example': patch
'@difizen/mana-ui': patch
'@difizen/mana-docs': patch
---

You can now define metadata for views through view decorators, and view components can be React Lazy components, so dynamic components are also supported.
22 changes: 22 additions & 0 deletions packages/mana-core/src/view/decorator.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'react';
import assert from 'assert';
import 'reflect-metadata';

import { view } from './decorator';
import { BaseView } from './default-view';
import { ViewComponentToken, ViewDefineToken } from './view-protocol';

describe('app', () => {
it('#view factory', () => {
@view('foo')
class Foo extends BaseView {}
assert(Reflect.getMetadata(ViewDefineToken, Foo) === 'foo');
});
it('#view meta', () => {
const FooRender = () => <></>;
@view({ id: 'foo', component: FooRender })
class Foo extends BaseView {}
assert(Reflect.getMetadata(ViewDefineToken, Foo) === 'foo');
assert(Reflect.getMetadata(ViewComponentToken, Foo) === FooRender);
});
});
2 changes: 0 additions & 2 deletions packages/mana-core/src/view/decorator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { isPromise } from 'util/types';

import type { Newable } from '@difizen/mana-common';
import type { Syringe } from '@difizen/mana-syringe';
import { registerSideOption } from '@difizen/mana-syringe';
Expand Down

0 comments on commit 5af82e5

Please sign in to comment.