mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-22 18:35:31 -04:00
8b22f4f9fe
Signed-off-by: zhongjianfei <zhongjianfei@huawei.com> Change-Id: I2f4b3d48538c7e3d8172461fcb3b50f3299e339a
41 lines
1.7 KiB
JavaScript
41 lines
1.7 KiB
JavaScript
import { paramMock } from "../utils"
|
|
|
|
export function mockUtil() {
|
|
const result = {
|
|
TextDecoder: function(...args) {
|
|
console.warn("util.TextDecoder interface mocked in the Previewer. How this interface works on the Previewer" +
|
|
" may be different from that on a real device.")
|
|
return TextDecoderMock;
|
|
},
|
|
TextEncoder: function(...args) {
|
|
console.warn("util.TextEncoder interface mocked in the Previewer. How this interface works on the Previewer" +
|
|
" may be different from that on a real device.")
|
|
return TextEncoderMock;
|
|
}
|
|
}
|
|
const TextDecoderMock = {
|
|
encoding: '[PC preview] unknow encoding',
|
|
fatal: '[PC preview] unknow fatal',
|
|
ignoreBOM: '[PC preview] unknow ignoreBOM',
|
|
decode: function (...args) {
|
|
console.warn("TextDecoder.decode interface mocked in the Previewer. How this interface works on the Previewer" +
|
|
" may be different from that on a real device.")
|
|
return paramMock.paramStringMock;
|
|
},
|
|
}
|
|
const TextEncoderMock = {
|
|
encoding: '[PC preview] unknow encoding',
|
|
encode: function(...args) {
|
|
console.warn("TextEncoder.encode interface mocked in the Previewer. How this interface works on the Previewer" +
|
|
" may be different from that on a real device.")
|
|
return paramMock.paramArrayMock;
|
|
},
|
|
encodeInto: function(...args) {
|
|
console.warn("TextEncoder.encodeInto interface mocked in the Previewer. How this interface works on the Previewer" +
|
|
" may be different from that on a real device.")
|
|
return paramMock.paramObjectMock;
|
|
}
|
|
}
|
|
return result;
|
|
}
|