• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 = `
17@Component
18@Entry
19struct MyComponent {
20    private value1: string = "hello world 1"
21    private value2: string = "hello world 2"
22    private value3: string = "hello world 3"
23
24    build() {
25        Column() {
26            Text(this.value1)
27            Text(this.value2)
28            Text(this.value3)
29        }
30    }
31}`
32
33exports.expectResult =
34`"use strict";
35class MyComponent extends View {
36    constructor(compilerAssignedUniqueChildId, parent, params) {
37        super(compilerAssignedUniqueChildId, parent);
38        this.value1 = "hello world 1";
39        this.value2 = "hello world 2";
40        this.value3 = "hello world 3";
41        this.updateWithValueParams(params);
42    }
43    updateWithValueParams(params) {
44        if (params.value1 !== undefined) {
45            this.value1 = params.value1;
46        }
47        if (params.value2 !== undefined) {
48            this.value2 = params.value2;
49        }
50        if (params.value3 !== undefined) {
51            this.value3 = params.value3;
52        }
53    }
54    aboutToBeDeleted() {
55        SubscriberManager.Get().delete(this.id());
56    }
57    render() {
58        Column.create();
59        Text.create(this.value1);
60        Text.pop();
61        Text.create(this.value2);
62        Text.pop();
63        Text.create(this.value3);
64        Text.pop();
65        Column.pop();
66    }
67}
68loadDocument(new MyComponent("1", undefined, {}));
69`
70