• 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 mockLightWeightSet() {
19  const paramLightWeightSet = {
20    paramAnyMock: '[PC Preview] unknow any',
21    paramIterMock_T: '[PC Preview] unknow IterableIterator_t'
22  }
23  const LightWeightSetClass = class LightWeightSet {
24    constructor(...args) {
25      console.warn('util.LightWeightSet interface mocked in the Previewer. How this interface works on the Previewer' +
26        ' may be different from that on a real device.');
27      this.length = '[PC preview] unknow length';
28      this.add = function (...args) {
29        console.warn("LightWeightSet.add interface mocked in the Previewer. How this interface works on the Previewer" +
30          " may be different from that on a real device.")
31        return paramMock.paramBooleanMock;
32      };
33      this.addAll = function (...args) {
34        console.warn("LightWeightSet.addAll interface mocked in the Previewer. How this interface works on the Previewer" +
35          " may be different from that on a real device.")
36        return paramMock.paramBooleanMock;
37      };
38      this.hasAll = function (...args) {
39        console.warn("LightWeightSet.hasAll interface mocked in the Previewer. How this interface works on the Previewer" +
40          " may be different from that on a real device.")
41        return paramMock.paramBooleanMock;
42      };
43      this.has = function (...args) {
44        console.warn("LightWeightSet.has interface mocked in the Previewer. How this interface works on the Previewer" +
45          " may be different from that on a real device.")
46        return paramMock.paramBooleanMock;
47      };
48      this.equal = function (...args) {
49        console.warn("LightWeightSet.equal interface mocked in the Previewer. How this interface works on the Previewer" +
50          " may be different from that on a real device.")
51        return paramMock.paramBooleanMock;
52      };
53      this.increaseCapacityTo = function (...args) {
54        console.warn("LightWeightSet.increaseCapacityTo interface mocked in the Previewer. How this interface works on the Previewer" +
55          " may be different from that on a real device.")
56      };
57      this.getIndexOf = function (...args) {
58        console.warn("LightWeightSet.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" +
59          " may be different from that on a real device.")
60        return paramMock.paramNumberMock;
61      };
62      this.remove = function (...args) {
63        console.warn("LightWeightSet.remove interface mocked in the Previewer. How this interface works on the Previewer" +
64          " may be different from that on a real device.")
65        return paramLightWeightSet.paramAnyMock;
66      };
67      this.removeAt = function (...args) {
68        console.warn("LightWeightSet.removeAt interface mocked in the Previewer. How this interface works on the Previewer" +
69          " may be different from that on a real device.")
70        return paramMock.paramBooleanMock;
71      };
72      this.clear = function (...args) {
73        console.warn("LightWeightSet.clear interface mocked in the Previewer. How this interface works on the Previewer" +
74          " may be different from that on a real device.")
75      };
76      this.forEach = function (...args) {
77        console.warn("LightWeightSet.forEach interface mocked in the Previewer. How this interface works on the Previewer" +
78          " may be different from that on a real device.")
79        if (this.args[0] === 'function') {
80          args[0].call(this, paramMock.businessErrorMock);
81        }
82      };
83      this.toString = function (...args) {
84        console.warn("LightWeightSet.toString interface mocked in the Previewer. How this interface works on the Previewer" +
85          " may be different from that on a real device.")
86        return paramMock.paramStringMock;
87      };
88      this.toString = function (...args) {
89        console.warn("LightWeightSet.toString interface mocked in the Previewer. How this interface works on the Previewer" +
90          " may be different from that on a real device.")
91        return paramMock.paramStringMock;
92      };
93      this.toArray = function (...args) {
94        console.warn("LightWeightSet.toArray interface mocked in the Previewer. How this interface works on the Previewer" +
95          " may be different from that on a real device.")
96        return paramMock.paramArrayMock;
97      };
98      this.getValueAt = function (...args) {
99        console.warn("LightWeightSet.getValueAt interface mocked in the Previewer. How this interface works on the Previewer" +
100          " may be different from that on a real device.")
101        return paramLightWeightSet.paramAnyMock;
102      };
103      this.values = function (...args) {
104        console.warn('LightWeightSet.values interface mocked in the Previewer. How this interface works on the Previewer' +
105          ' may be different from that on a real device.');
106        const IteratorVMock = {
107          *[Symbol.iterator]() {
108            yield paramLightWeightSet.paramIterMock_T;
109          }
110        };
111        return IteratorVMock;
112      };
113      this.entries = function (...args) {
114        console.warn('LightWeightSet.entries interface mocked in the Previewer. How this interface works on the Previewer' +
115          ' may be different from that on a real device.');
116        const IteratorEntriesMock = {
117          *[Symbol.iterator]() {
118            yield [paramLightWeightSet.paramIterMock_T, paramLightWeightSet.paramIterMock_T];
119          }
120        };
121        return IteratorEntriesMock;
122      };
123      this.isEmpty = function (...args) {
124        console.warn("LightWeightSet.isEmpty interface mocked in the Previewer. How this interface works on the Previewer" +
125          " may be different from that on a real device.")
126        return paramMock.paramBooleanMock;
127      };
128      this[Symbol.iterator] = function (...args) {
129        console.warn("LightWeightSet.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" +
130          " may be different from that on a real device.")
131        let index = 0;
132        const IteratorMock = {
133          next: () => {
134            if (index < 1) {
135              const returnValue = [paramLightWeightSet.paramIterMock_T, paramLightWeightSet.paramIterMock_T];
136              index++;
137              return {
138                value: returnValue,
139                done: false
140              };
141            } else {
142              return {
143                done: true
144              };
145            }
146          }
147        };
148        return IteratorMock;
149      }
150    }
151  }
152  return LightWeightSetClass;
153}