• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16import { paramMock } from "../utils"
17
18export function mockTreeSet() {
19  const paramTreeSet = {
20    paramAnyMock: '[PC Preview] unknow any',
21    paramIterMock_TT: '[PC Preview] unknow IterableIterator_tt',
22    paramIterMock: '[PC Preview] unknow IterableIterator'
23  }
24  const TreeSetClass = class TreeSet {
25    constructor(...args) {
26      console.warn('util.TreeSet interface mocked in the Previewer. How this interface works on the Previewer' +
27        ' may be different from that on a real device.');
28      this.length = '[PC preview] unknow length';
29      this.isEmpty = function (...args) {
30        console.warn("TreeSet.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" +
31          " may be different from that on a real device.")
32        return paramMock.paramBooleanMock;
33      };
34      this.has = function (...args) {
35        console.warn("TreeSet.has interface mocked in the Previewer. How this interface works on the Previewer" +
36          " may be different from that on a real device.")
37        return paramMock.paramBooleanMock;
38      };
39      this.add = function (...args) {
40        console.warn("TreeSet.add interface mocked in the Previewer. How this interface works on the Previewer" +
41          " may be different from that on a real device.")
42        return paramMock.paramBooleanMock;
43      };
44      this.remove = function (...args) {
45        console.warn("TreeSet.remove interface mocked in the Previewer. How this interface works on the Previewer" +
46          " may be different from that on a real device.")
47        return paramMock.paramBooleanMock;
48      };
49      this.clear = function (...args) {
50        console.warn("TreeSet.clear interface mocked in the Previewer. How this interface works on the Previewer" +
51          " may be different from that on a real device.")
52      };
53      this.getFirstValue = function (...args) {
54        console.warn("TreeSet.getFirstValue interface mocked in the Previewer. How this interface works on the Previewer" +
55          " may be different from that on a real device.")
56        return paramTreeSet.paramAnyMock;
57      };
58      this.getLastValue = function (...args) {
59        console.warn("TreeSet.getLastValue interface mocked in the Previewer. How this interface works on the Previewer" +
60          " may be different from that on a real device.")
61        return paramTreeSet.paramAnyMock;
62      };
63      this.getLowerValue = function (...args) {
64        console.warn("TreeSet.getLowerValue interface mocked in the Previewer. How this interface works on the Previewer" +
65          " may be different from that on a real device.")
66        return paramTreeSet.paramAnyMock;
67      };
68      this.getHigherValue = function (...args) {
69        console.warn("TreeSet.getHigherValue interface mocked in the Previewer. How this interface works on the Previewer" +
70          " may be different from that on a real device.")
71        return paramTreeSet.paramAnyMock;
72      };
73      this.popFirst = function (...args) {
74        console.warn("TreeSet.popFirst interface mocked in the Previewer. How this interface works on the Previewer" +
75          " may be different from that on a real device.")
76        return paramTreeSet.paramAnyMock;
77      };
78      this.popLast = function (...args) {
79        console.warn("TreeSet.popLast interface mocked in the Previewer. How this interface works on the Previewer" +
80          " may be different from that on a real device.")
81        return paramTreeSet.paramAnyMock;
82      };
83      this.forEach = function (...args) {
84        console.warn("TreeSet.forEach interface mocked in the Previewer. How this interface works on the Previewer" +
85          " may be different from that on a real device.")
86        if (typeof args[0] === 'function') {
87          args[0].call(this, paramMock.businessErrorMock)
88        }
89      };
90      this.values = function (...args) {
91        console.warn("TreeSet.values interface mocked in the Previewer. How this interface works on the Previewer" +
92          " may be different from that on a real device.")
93        const IteratorVMock = {
94          *[Symbol.iterator]() {
95            yield paramTreeSet.paramIterMock_TT;
96          }
97        };
98        return IteratorVMock;
99      };
100      this.entries = function (...args) {
101        console.warn("TreeSet.entries interface mocked in the Previewer. How this interface works on the Previewer" +
102          " may be different from that on a real device.")
103        const IteratorVMock = {
104          *[Symbol.iterator]() {
105            yield paramTreeSet.paramIterMock;
106          }
107        };
108        return IteratorVMock;
109      };
110      this[Symbol.iterator] = function (...args) {
111        console.warn("TreeSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" +
112          " may be different from that on a real device.")
113        let index = 0;
114        const IteratorMock = {
115          next: () => {
116            if (index < 1) {
117              index++;
118              return {
119                value: paramTreeSet.paramAnyMock,
120                done: false
121              };
122            } else {
123              return {
124                done: true
125              };
126            }
127          }
128        };
129        return IteratorMock;
130      }
131    }
132  }
133  return TreeSetClass;
134}