• 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 mockLinkedList() {
19  const paramLinkedList = {
20    paramAnyMock: '[PC Preview] unknow any',
21    paramLinkedListMock: '[PC Preview] unknow LinkedList',
22    paramIterMock: '[PC Preview] unknow IterableIterator'
23  }
24  const LinkedListClass = class LinkedList {
25    constructor(...args) {
26      console.warn('util.LinkedList 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.add = function (...args) {
30        console.warn("LinkedList.add 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.insert = function (...args) {
35        console.warn("LinkedList.insert interface mocked in the Previewer. How this interface works on the Previewer" +
36          " may be different from that on a real device.")
37      };
38      this.get = function (...args) {
39        console.warn("LinkedList.get interface mocked in the Previewer. How this interface works on the Previewer" +
40          " may be different from that on a real device.")
41        return paramLinkedList.paramAnyMock;
42      };
43      this.addFirst = function (...args) {
44        console.warn("LinkedList.addFirst interface mocked in the Previewer. How this interface works on the Previewer" +
45          " may be different from that on a real device.")
46      };
47      this.removeFirst = function (...args) {
48        console.warn("LinkedList.removeFirst interface mocked in the Previewer. How this interface works on the Previewer" +
49          " may be different from that on a real device.")
50        return paramLinkedList.paramAnyMock;
51      };
52      this.removeLast = function (...args) {
53        console.warn("LinkedList.removeLast interface mocked in the Previewer. How this interface works on the Previewer" +
54          " may be different from that on a real device.")
55        return paramLinkedList.paramAnyMock;
56      };
57      this.has = function (...args) {
58        console.warn("LinkedList.has 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.paramBooleanMock;
61      };
62      this.getIndexOf = function (...args) {
63        console.warn("LinkedList.getIndexOf interface mocked in the Previewer. How this interface works on the Previewer" +
64          " may be different from that on a real device.")
65        return paramMock.paramNumberMock;
66      };
67      this.removeByIndex = function (...args) {
68        console.warn("LinkedList.removeByIndex interface mocked in the Previewer. How this interface works on the Previewer" +
69          " may be different from that on a real device.")
70        return paramLinkedList.paramAnyMock;
71      };
72      this.remove = function (...args) {
73        console.warn("LinkedList.remove interface mocked in the Previewer. How this interface works on the Previewer" +
74          " may be different from that on a real device.")
75        return paramMock.paramBooleanMock;
76      };
77      this.removeFirstFound = function (...args) {
78        console.warn("LinkedList.removeFirstFound interface mocked in the Previewer. How this interface works on the Previewer" +
79          " may be different from that on a real device.")
80        return paramMock.paramBooleanMock;
81      };
82      this.removeLastFound = function (...args) {
83        console.warn("LinkedList.removeLastFound interface mocked in the Previewer. How this interface works on the Previewer" +
84          " may be different from that on a real device.")
85        return paramMock.paramBooleanMock;
86      };
87      this.getLastIndexOf = function (...args) {
88        console.warn("LinkedList.getLastIndexOf interface mocked in the Previewer. How this interface works on the Previewer" +
89          " may be different from that on a real device.")
90        return paramMock.paramNumberMock;
91      };
92      this.getFirst = function (...args) {
93        console.warn("LinkedList.getFirst interface mocked in the Previewer. How this interface works on the Previewer" +
94          " may be different from that on a real device.")
95        return paramLinkedList.paramAnyMock;
96      };
97      this.getLast = function (...args) {
98        console.warn("LinkedList.getLast interface mocked in the Previewer. How this interface works on the Previewer" +
99          " may be different from that on a real device.")
100        return paramLinkedList.paramAnyMock;
101      };
102      this.set = function (...args) {
103        console.warn("LinkedList.set interface mocked in the Previewer. How this interface works on the Previewer" +
104          " may be different from that on a real device.")
105        return paramLinkedList.paramAnyMock;
106      };
107      this.forEach = function (...args) {
108        console.warn("LinkedList.forEach interface mocked in the Previewer. How this interface works on the Previewer" +
109          " may be different from that on a real device.")
110        if (typeof args[0] === 'function') {
111          args[0].call(this, paramMock.businessErrorMock)
112        }
113      };
114      this.clear = function (...args) {
115        console.warn("LinkedList.clear interface mocked in the Previewer. How this interface works on the Previewer" +
116          " may be different from that on a real device.")
117      };
118      this.clone = function (...args) {
119        console.warn("LinkedList.clone interface mocked in the Previewer. How this interface works on the Previewer" +
120          " may be different from that on a real device.")
121        return paramLinkedList.paramLinkedListMock;
122      };
123      this.convertToArray = function (...args) {
124        console.warn("LinkedList.convertToArray 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.paramArrayMock;
127      };
128      this[Symbol.iterator] = function (...args) {
129        console.warn("LinkedList.[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              index++;
136              return {
137                value: paramLinkedList.paramAnyMock,
138                done: false
139              };
140            } else {
141              return {
142                done: true
143              };
144            }
145          }
146        };
147        return IteratorMock;
148      }
149    }
150  }
151  return LinkedListClass;
152}