• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2020 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16exports.source = `
17import { AllStarComponent } from './test/pages/ExportStarComponent'
18import TsModule from './test/pages/TsModule'
19
20@Entry
21@Component
22struct ImportTest {
23  @State myState1: any = new TsModule(1).method();
24  @State myState2: number = 0
25  @State myState3: boolean = false
26  @State myState4: string = 'ImportTest'
27
28  build() {
29    Row() {
30      AllStarComponent.ExportComponent({
31        ExportComponent1Link1: $myState1,
32        ExportComponent1Link2: this.$myState2,
33        ExportComponent1Link3: $myState3,
34        ExportComponent1Link4: $myState4,
35        indexState1: { count: 1 },
36        indexState2: 1,
37        indexState3: true,
38        indexState4: 'ExportComponent1'
39      })
40      AllStarComponent.default({
41        ExportComponent4Link1: $myState1,
42        ExportComponent4Link2: this.$myState2,
43        ExportComponent4Link3: $myState3,
44        ExportComponent4Link4: $myState4,
45        indexState1: { count: 1 },
46        indexState2: 1,
47        indexState3: true,
48        indexState4: 'ExportComponent4'
49      })
50    }
51  }
52}
53`
54
55exports.expectResult =
56`"use strict";
57var __importDefault = (this && this.__importDefault) || function (mod) {
58    return (mod && mod.__esModule) ? mod : { "default": mod };
59};
60Object.defineProperty(exports, "__esModule", { value: true });
61const ExportStarComponent_1 = require("./test/pages/ExportStarComponent");
62const TsModule_1 = __importDefault(require("./test/pages/TsModule"));
63class ImportTest extends View {
64    constructor(compilerAssignedUniqueChildId, parent, params) {
65        super(compilerAssignedUniqueChildId, parent);
66        this.__myState1 = new ObservedPropertyObject(new TsModule_1.default(1).method(), this, "myState1");
67        this.__myState2 = new ObservedPropertySimple(0, this, "myState2");
68        this.__myState3 = new ObservedPropertySimple(false, this, "myState3");
69        this.__myState4 = new ObservedPropertySimple('ImportTest', this, "myState4");
70        this.updateWithValueParams(params);
71    }
72    updateWithValueParams(params) {
73        if (params.myState1 !== undefined) {
74            this.myState1 = params.myState1;
75        }
76        if (params.myState2 !== undefined) {
77            this.myState2 = params.myState2;
78        }
79        if (params.myState3 !== undefined) {
80            this.myState3 = params.myState3;
81        }
82        if (params.myState4 !== undefined) {
83            this.myState4 = params.myState4;
84        }
85    }
86    aboutToBeDeleted() {
87        this.__myState1.aboutToBeDeleted();
88        this.__myState2.aboutToBeDeleted();
89        this.__myState3.aboutToBeDeleted();
90        this.__myState4.aboutToBeDeleted();
91        SubscriberManager.Get().delete(this.id());
92    }
93    get myState1() {
94        return this.__myState1.get();
95    }
96    set myState1(newValue) {
97        this.__myState1.set(newValue);
98    }
99    get myState2() {
100        return this.__myState2.get();
101    }
102    set myState2(newValue) {
103        this.__myState2.set(newValue);
104    }
105    get myState3() {
106        return this.__myState3.get();
107    }
108    set myState3(newValue) {
109        this.__myState3.set(newValue);
110    }
111    get myState4() {
112        return this.__myState4.get();
113    }
114    set myState4(newValue) {
115        this.__myState4.set(newValue);
116    }
117    render() {
118        Row.create();
119        let earlierCreatedChild_2 = this.findChildById("2");
120        if (earlierCreatedChild_2 == undefined) {
121            View.create(new ExportStarComponent_1.AllStarComponent.ExportComponent("2", this, {
122                ExportComponent1Link1: this.__myState1,
123                ExportComponent1Link2: this.__myState2,
124                ExportComponent1Link3: this.__myState3,
125                ExportComponent1Link4: this.__myState4,
126                indexState1: { count: 1 },
127                indexState2: 1,
128                indexState3: true,
129                indexState4: 'ExportComponent1'
130            }));
131        }
132        else {
133            earlierCreatedChild_2.updateWithValueParams({
134                indexState1: { count: 1 },
135                indexState2: 1,
136                indexState3: true,
137                indexState4: 'ExportComponent1'
138            });
139            View.create(earlierCreatedChild_2);
140        }
141        let earlierCreatedChild_3 = this.findChildById("3");
142        if (earlierCreatedChild_3 == undefined) {
143            View.create(new ExportStarComponent_1.AllStarComponent.default("3", this, {
144                ExportComponent4Link1: this.__myState1,
145                ExportComponent4Link2: this.__myState2,
146                ExportComponent4Link3: this.__myState3,
147                ExportComponent4Link4: this.__myState4,
148                indexState1: { count: 1 },
149                indexState2: 1,
150                indexState3: true,
151                indexState4: 'ExportComponent4'
152            }));
153        }
154        else {
155            earlierCreatedChild_3.updateWithValueParams({
156                indexState1: { count: 1 },
157                indexState2: 1,
158                indexState3: true,
159                indexState4: 'ExportComponent4'
160            });
161            View.create(earlierCreatedChild_3);
162        }
163        Row.pop();
164    }
165}
166loadDocument(new ImportTest("1", undefined, {}));
167`