1/*
2 * Copyright (c) 2022 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    Column() {
30      AllStarComponent.ExportComponent({
31        ExportComponent1Link1: $myState1,
32        ExportComponent1Link2: $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: $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 });
61let __generate__Id = 0;
62function generateId() {
63    return "importTs_" + ++__generate__Id;
64}
65const ExportStarComponent_1 = require("./test/pages/ExportStarComponent");
66const TsModule_1 = __importDefault(require("./test/pages/TsModule"));
67class ImportTest extends View {
68    constructor(compilerAssignedUniqueChildId, parent, params, localStorage) {
69        super(compilerAssignedUniqueChildId, parent, localStorage);
70        this.__myState1 = new ObservedPropertyObject(new TsModule_1.default(1).method(), this, "myState1");
71        this.__myState2 = new ObservedPropertySimple(0, this, "myState2");
72        this.__myState3 = new ObservedPropertySimple(false, this, "myState3");
73        this.__myState4 = new ObservedPropertySimple('ImportTest', this, "myState4");
74        this.updateWithValueParams(params);
75    }
76    updateWithValueParams(params) {
77        if (params.myState1 !== undefined) {
78            this.myState1 = params.myState1;
79        }
80        if (params.myState2 !== undefined) {
81            this.myState2 = params.myState2;
82        }
83        if (params.myState3 !== undefined) {
84            this.myState3 = params.myState3;
85        }
86        if (params.myState4 !== undefined) {
87            this.myState4 = params.myState4;
88        }
89    }
90    aboutToBeDeleted() {
91        this.__myState1.aboutToBeDeleted();
92        this.__myState2.aboutToBeDeleted();
93        this.__myState3.aboutToBeDeleted();
94        this.__myState4.aboutToBeDeleted();
95        SubscriberManager.Get().delete(this.id());
96    }
97    get myState1() {
98        return this.__myState1.get();
99    }
100    set myState1(newValue) {
101        this.__myState1.set(newValue);
102    }
103    get myState2() {
104        return this.__myState2.get();
105    }
106    set myState2(newValue) {
107        this.__myState2.set(newValue);
108    }
109    get myState3() {
110        return this.__myState3.get();
111    }
112    set myState3(newValue) {
113        this.__myState3.set(newValue);
114    }
115    get myState4() {
116        return this.__myState4.get();
117    }
118    set myState4(newValue) {
119        this.__myState4.set(newValue);
120    }
121    render() {
122        Column.create();
123        let earlierCreatedChild_2 = (this && this.findChildById) ? this.findChildById("2") : undefined;
124        if (earlierCreatedChild_2 == undefined) {
125            View.create(new ExportStarComponent_1.AllStarComponent.ExportComponent("2", this, {
126                ExportComponent1Link1: this.__myState1,
127                ExportComponent1Link2: this.__myState2,
128                ExportComponent1Link3: this.__myState3,
129                ExportComponent1Link4: this.__myState4,
130                indexState1: { count: 1 },
131                indexState2: 1,
132                indexState3: true,
133                indexState4: 'ExportComponent1'
134            }));
135        }
136        else {
137            earlierCreatedChild_2.updateWithValueParams({
138                indexState1: { count: 1 },
139                indexState2: 1,
140                indexState3: true,
141                indexState4: 'ExportComponent1'
142            });
143            View.create(earlierCreatedChild_2);
144        }
145        let earlierCreatedChild_3 = (this && this.findChildById) ? this.findChildById("3") : undefined;
146        if (earlierCreatedChild_3 == undefined) {
147            View.create(new ExportStarComponent_1.AllStarComponent.default("3", this, {
148                ExportComponent4Link1: this.__myState1,
149                ExportComponent4Link2: this.__myState2,
150                ExportComponent4Link3: this.__myState3,
151                ExportComponent4Link4: this.__myState4,
152                indexState1: { count: 1 },
153                indexState2: 1,
154                indexState3: true,
155                indexState4: 'ExportComponent4'
156            }));
157        }
158        else {
159            earlierCreatedChild_3.updateWithValueParams({
160                indexState1: { count: 1 },
161                indexState2: 1,
162                indexState3: true,
163                indexState4: 'ExportComponent4'
164            });
165            View.create(earlierCreatedChild_3);
166        }
167        Column.pop();
168    }
169}
170loadDocument(new ImportTest("1", undefined, {}));
171`
172