• 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@Entry
18@Component
19struct MyComponent {
20    private test: string = 'Hello'
21    build() {
22        Column() {
23        Text(this.test)
24        ForEach(
25            weekNames,
26            (item, index) => {
27            GridItem() {
28                Text(item)
29                .fontSize(10)
30            }
31            },
32            (item, index) => item)
33        }.width(100)
34    }
35}`
36
37exports.expectResult =
38`"use strict";
39class MyComponent extends View {
40    constructor(compilerAssignedUniqueChildId, parent, params) {
41        super(compilerAssignedUniqueChildId, parent);
42        this.test = 'Hello';
43        this.updateWithValueParams(params);
44    }
45    updateWithValueParams(params) {
46        if (params.test !== undefined) {
47            this.test = params.test;
48        }
49    }
50    aboutToBeDeleted() {
51        SubscriberManager.Get().delete(this.id());
52    }
53    render() {
54        Column.create();
55        Column.width(100);
56        Text.create(this.test);
57        Text.pop();
58        ForEach.create("2", this, ObservedObject.GetRawObject(weekNames), (item, index) => {
59            GridItem.create();
60            Text.create(item);
61            Text.fontSize(10);
62            Text.pop();
63            GridItem.pop();
64        }, (item, index) => item);
65        ForEach.pop();
66        Column.pop();
67    }
68}
69loadDocument(new MyComponent("1", undefined, {}));
70`
71