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 mockDeque() { 19 const paramDeque = { 20 paramAnyMock: '[PC Preview] unknow any', 21 paramIterMock: '[PC Preview] unknow IterableIterator' 22 } 23 const DequeClass = class Deque { 24 constructor(...args) { 25 console.warn('util.Deque 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.insertFront = function (...args) { 29 console.warn("Deque.insertFront interface mocked in the Previewer. How this interface works on the Previewer" + 30 " may be different from that on a real device.") 31 }; 32 this.insertEnd = function (...args) { 33 console.warn("Deque.insertEnd interface mocked in the Previewer. How this interface works on the Previewer" + 34 " may be different from that on a real device.") 35 }; 36 this.has = function (...args) { 37 console.warn("Deque.has interface mocked in the Previewer. How this interface works on the Previewer" + 38 " may be different from that on a real device.") 39 return paramMock.paramBooleanMock; 40 }; 41 this.getFirst = function (...args) { 42 console.warn("Deque.getFirst interface mocked in the Previewer. How this interface works on the Previewer" + 43 " may be different from that on a real device.") 44 return paramDeque.paramAnyMock; 45 }; 46 this.getLast = function (...args) { 47 console.warn("Deque.getLast interface mocked in the Previewer. How this interface works on the Previewer" + 48 " may be different from that on a real device.") 49 return paramDeque.paramAnyMock; 50 }; 51 this.popFirst = function (...args) { 52 console.warn("Deque.popFirst interface mocked in the Previewer. How this interface works on the Previewer" + 53 " may be different from that on a real device.") 54 return paramDeque.paramAnyMock; 55 }; 56 this.popLast = function (...args) { 57 console.warn("Deque.popLast interface mocked in the Previewer. How this interface works on the Previewer" + 58 " may be different from that on a real device.") 59 return paramDeque.paramAnyMock; 60 }; 61 this.forEach = function (...args) { 62 console.warn("Deque.forEach interface mocked in the Previewer. How this interface works on the Previewer" + 63 " may be different from that on a real device.") 64 if (typeof args[0] === 'function') { 65 args[0].call(this, paramDeque.businessErrorMock) 66 } 67 }; 68 } 69 [Symbol.iterator]() { 70 console.warn("Deque.[Symbol.iterator] interface mocked in the Previewer. How this interface works on the Previewer" + 71 " may be different from that on a real device.") 72 let index = 0; 73 const IteratorMock = { 74 next: () => { 75 if (index < 1) { 76 index++; 77 return { 78 value: paramDeque.paramAnyMock, 79 done: false 80 }; 81 } else { 82 return { 83 done: true 84 }; 85 } 86 } 87 }; 88 return IteratorMock; 89 } 90 } 91 return DequeClass; 92}