mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
+2
-2
@@ -48,7 +48,7 @@ export interface Type<T> extends Function {
|
|||||||
|
|
||||||
export class Component<
|
export class Component<
|
||||||
T extends Env,
|
T extends Env,
|
||||||
Props,
|
Props extends {},
|
||||||
State extends {}
|
State extends {}
|
||||||
> extends EventBus {
|
> extends EventBus {
|
||||||
readonly __widget__: Meta<Env, Props>;
|
readonly __widget__: Meta<Env, Props>;
|
||||||
@@ -96,7 +96,7 @@ export class Component<
|
|||||||
// Pro: if props is empty, we can create easily a widget
|
// Pro: if props is empty, we can create easily a widget
|
||||||
// Con: this is not really safe
|
// Con: this is not really safe
|
||||||
// Pro: but creating widget (by a template) is always unsafe anyway
|
// Pro: but creating widget (by a template) is always unsafe anyway
|
||||||
this.props = <Props>props;
|
this.props = <Props>props || <Props>{};
|
||||||
let id: number = getId();
|
let id: number = getId();
|
||||||
let p: Component<T, any, any> | null = null;
|
let p: Component<T, any, any> | null = null;
|
||||||
if (parent instanceof Component) {
|
if (parent instanceof Component) {
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ class WidgetB extends Widget {
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
describe("basic widget properties", () => {
|
describe("basic widget properties", () => {
|
||||||
|
test("props and state are properly defined", async () => {
|
||||||
|
const widget = new Widget(env);
|
||||||
|
expect(widget.props).toEqual({});
|
||||||
|
expect(widget.state).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
test("has no el after creation", async () => {
|
test("has no el after creation", async () => {
|
||||||
const widget = new Widget(env);
|
const widget = new Widget(env);
|
||||||
expect(widget.el).toBe(null);
|
expect(widget.el).toBe(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user