• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import { paramMock } from "../utils"
2
3export function mockUtil() {
4    const result = {
5        TextDecoder: function(...args) {
6            console.warn("util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer" +
7                " may be different from that on a real device.")
8            return TextDecoderMock;
9        },
10        TextEncoder: function(...args) {
11            console.warn("util.TextEncoder interface mocked in the Previewer. How this interface works on the Previewer" +
12                " may be different from that on a real device.")
13            return TextEncoderMock;
14        }
15    }
16    const TextDecoderMock = {
17        encoding: '[PC preview] unknow encoding',
18        fatal: '[PC preview] unknow fatal',
19        ignoreBOM: '[PC preview] unknow ignoreBOM',
20        decode: function (...args) {
21            console.warn("TextDecoder.decode interface mocked in the Previewer. How this interface works on the Previewer" +
22                " may be different from that on a real device.")
23            return paramMock.paramStringMock;
24        },
25    }
26    const TextEncoderMock = {
27        encoding: '[PC preview] unknow encoding',
28        encode: function(...args) {
29            console.warn("TextEncoder.encode 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.paramArrayMock;
32        },
33        encodeInto: function(...args) {
34            console.warn("TextEncoder.encodeInto 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.paramObjectMock;
37        }
38    }
39    return result;
40}
41