mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-18 20:44:48 -04:00
update intl and i18n js mock
Signed-off-by: sunyaozu <sunyaozu@huawei.com>
This commit is contained in:
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { paramMock } from "./utils"
|
||||
|
||||
export function mockI18n() {
|
||||
function TimeZone(timeZoneId, module) {
|
||||
var i18nModuleGroup = module;
|
||||
var zone = timeZoneId;
|
||||
|
||||
this.getID = getID;
|
||||
function getID() {
|
||||
console.warn("I18n.TimeZone.getID interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
}
|
||||
|
||||
this.getDisplayName = getDisplayName;
|
||||
function getDisplayName(...args) {
|
||||
console.warn("I18n.TimeZone.getDisplayName interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
}
|
||||
|
||||
this.getRawOffset = getRawOffset;
|
||||
function getRawOffset() {
|
||||
console.warn("I18n.TimeZone.getRawOffset interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramNumberMock;
|
||||
}
|
||||
|
||||
this.getOffset = getOffset;
|
||||
function getOffset(...args) {
|
||||
console.warn("I18n.TimeZone.getOffset interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramNumberMock;
|
||||
}
|
||||
}
|
||||
|
||||
var i18n = {
|
||||
i18nModuleGroup: null,
|
||||
|
||||
getDisplayLanguage: function getDisplayLanguage(...args) {
|
||||
console.warn("I18n.getDisplayLanguage interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
getDisplayCountry: function getDisplayCountry(...args) {
|
||||
console.warn("I18n.getDisplayCountry interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
isRTL: function isRTL(locale) {
|
||||
console.warn("I18n.isRTL interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
isSuggested: function isSuggested(...args) {
|
||||
console.warn("I18n.isSuggested interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
is24HourClock: function is24HourClock() {
|
||||
console.warn("I18n.is24HourClock interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
set24HourClock: function set24HourClock(is24Hour) {
|
||||
console.warn("I18n.set24HourClock interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
},
|
||||
|
||||
getSystemLanguages: function getSystemLanguages() {
|
||||
console.warn("I18n.getSystemLanguages interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
|
||||
getSystemCountries: function getSystemCountries(locale) {
|
||||
console.warn("I18n.getSystemCountries interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
|
||||
getTimeZone: function getTimeZone() {
|
||||
console.warn("I18n.getTimeZone interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
let data = new TimeZone("mockTimeZoneID", null);
|
||||
return data;
|
||||
},
|
||||
|
||||
getTimeZone: function getTimeZone(zoneId) {
|
||||
console.warn("I18n.getTimeZone interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
let data = new TimeZone(zoneId, null);
|
||||
return data;
|
||||
},
|
||||
|
||||
getSystemLanguage: function getSystemLanguage() {
|
||||
console.warn("I18n.getSystemLanguage interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
getSystemRegion: function getSystemRegion() {
|
||||
console.warn("I18n.getSystemRegion interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
getSystemLocale: function getSystemLocale() {
|
||||
console.warn("I18n.getSystemLocale interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
|
||||
setSystemLanguage: function setSystemLanguage(language) {
|
||||
console.warn("I18n.setSystemLanguage interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
setSystemRegion: function setSystemRegion(region) {
|
||||
console.warn("I18n.setSystemRegion interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
|
||||
setSystemLocale: function setSystemLocale(locale) {
|
||||
console.warn("I18n.setSystemLocale interface mocked in the Previewer. " +
|
||||
"How this interface works on the Previewer may be different from that on a real device.");
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
};
|
||||
|
||||
global.systemplugin.i18n = {
|
||||
getDisplayLanguage: i18n.getDisplayLanguage,
|
||||
getDisplayCountry: i18n.getDisplayCountry,
|
||||
getSystemLanguages: i18n.getSystemLanguages,
|
||||
getSystemCountries: i18n.getSystemCountries,
|
||||
is24HourClock: i18n.is24HourClock,
|
||||
set24HourClock: i18n.set24HourClock,
|
||||
isSuggested: i18n.isSuggested,
|
||||
isRTL: i18n.isRTL,
|
||||
getTimeZone: i18n.getTimeZone,
|
||||
getSystemLanguage: i18n.getSystemLanguage,
|
||||
getSystemRegion: i18n.getSystemRegion,
|
||||
getSystemLocale: i18n.getSystemLocale,
|
||||
setSystemLanguage: i18n.setSystemLanguage,
|
||||
setSystemRegion: i18n.setSystemRegion,
|
||||
setSystemLocale: i18n.setSystemLocale,
|
||||
};
|
||||
};
|
||||
@@ -29,7 +29,6 @@ import { mockFile } from './file'
|
||||
import { mockGeolocation } from './geolocation'
|
||||
import { mockInputMethod } from './inputMethod'
|
||||
import { mockInputMethodEngine } from './inputMethodEngine'
|
||||
import { mockI18n } from './i18n'
|
||||
import {
|
||||
mockMultimediaImage,
|
||||
mockMultimediaMedia,
|
||||
@@ -118,7 +117,6 @@ export function mockSystemPlugin() {
|
||||
mockWallpaper()
|
||||
mockInputMethod()
|
||||
mockInputMethodEngine()
|
||||
mockI18n()
|
||||
mockOhosRequest()
|
||||
mockMultimediaImage()
|
||||
mockMultimediaMedia()
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { paramMock } from "../utils"
|
||||
|
||||
export function mockI18N() {
|
||||
const result = {
|
||||
getDisplayCountry: function(country, locale, sentenceCase) {
|
||||
console.warn("I18N.getDisplayCountry interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getDisplayLanguage: function(language, locale, sentenceCase) {
|
||||
console.warn("I18N.getDisplayLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getSystemLanguages: function() {
|
||||
console.warn("I18N.getSystemLanguages interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
getSystemCountries: function(language) {
|
||||
console.warn("I18N.getSystemCountries interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
isSuggested: function(language, region) {
|
||||
console.warn("I18N.isSuggested interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getSystemLanguage: function() {
|
||||
console.warn("I18N.getSystemLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
setSystemLanguage: function(language) {
|
||||
console.warn("I18N.setSystemLanguage interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getSystemRegion: function() {
|
||||
console.warn("I18N.getSystemRegion interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
setSystemRegion: function(region) {
|
||||
console.warn("I18N.setSystemRegion interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getSystemLocale: function() {
|
||||
console.warn("I18N.getSystemLocale interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
setSystemLocale: function(locale) {
|
||||
console.warn("I18N.setSystemLocale interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
PhoneNumberFormat: function(...args) {
|
||||
console.warn("I18N.PhoneNumberFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return PhoneNumberFormatMock;
|
||||
},
|
||||
getCalendar: function(...args) {
|
||||
console.warn("I18N.getCalendar interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return CalendarMock;
|
||||
},
|
||||
isRTL: function(locale) {
|
||||
console.warn("I18N.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getLineInstance: function(locale) {
|
||||
console.warn("I18N.getLineInstance interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return BreakIteratorMock;
|
||||
},
|
||||
Util: {
|
||||
unitConvert: function(...args) {
|
||||
console.warn("I18N.Util.unitConvert interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
}
|
||||
},
|
||||
IndexUtil: {
|
||||
getInstance: function() {
|
||||
console.warn("I18N.IndexUtil.getInstance interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return IndexUtilMock;
|
||||
}
|
||||
},
|
||||
Character: {
|
||||
isDigit: function(char) {
|
||||
console.warn("I18N.Character.isDigit interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isSpaceChar: function(char) {
|
||||
console.warn("I18N.Character.isSpaceChar interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isWhitespace: function(char) {
|
||||
console.warn("I18N.Character.isWhitespace interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isRTL: function(char) {
|
||||
console.warn("I18N.Character.isRTL interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isIdeograph: function(char) {
|
||||
console.warn("I18N.Character.isIdeograph interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isLetter: function(char) {
|
||||
console.warn("I18N.Character.isLetter interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isLowerCase: function(char) {
|
||||
console.warn("I18N.Character.isLowerCase interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
isUpperCase: function(char) {
|
||||
console.warn("I18N.Character.isUpperCase interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
getType: function(char) {
|
||||
console.warn("I18N.Character.getType 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 PhoneNumberFormatMock = {
|
||||
isValidNumber: function(number) {
|
||||
console.warn("I18N.PhoneNumberFormat.isValidNumber interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
format: function(number) {
|
||||
console.warn("I18N.PhoneNumberFormat.format 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 CalendarMock = {
|
||||
setTime: function(date) {
|
||||
console.warn("I18N.Calendar.setTime interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
set: function(...args) {
|
||||
console.warn("I18N.Calendar.set interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
setTimeZone: function(timezone) {
|
||||
console.warn("I18N.Calendar.setTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getTimeZone: function() {
|
||||
console.warn("I18N.Calendar.getTimeZone interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
getFirstDayOfWeek: function() {
|
||||
console.warn("I18N.Calendar.getFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
setFirstDayOfWeek: function(value) {
|
||||
console.warn("I18N.Calendar.setFirstDayOfWeek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getMinimalDaysInFirstWeek: function() {
|
||||
console.warn("I18N.Calendar.getMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
setMinimalDaysInFirstWeek: function(value) {
|
||||
console.warn("I18N.Calendar.setMinimalDaysInFirstWeek interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
get: function(field) {
|
||||
console.warn("I18N.Calendar.get interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getDisplayName: function(locale) {
|
||||
console.warn("I18N.Calendar.getDisplayName interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
isWeekend: function(...args) {
|
||||
console.warn("I18N.Calendar.isWeekend interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
}
|
||||
const BreakIteratorMock = {
|
||||
current: function() {
|
||||
console.warn("I18N.BreakIterator.current interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
first: function() {
|
||||
console.warn("I18N.BreakIterator.first interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
last: function() {
|
||||
console.warn("I18N.BreakIterator.last interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
next: function(...args) {
|
||||
console.warn("I18N.BreakIterator.next interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
previous: function() {
|
||||
console.warn("I18N.BreakIterator.previous interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
setLineBreakText: function() {
|
||||
console.warn("I18N.BreakIterator.setLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
following: function() {
|
||||
console.warn("I18N.BreakIterator.following interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
getLineBreakText: function() {
|
||||
console.warn("I18N.BreakIterator.getLineBreakText interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
isBoundary: function(offset) {
|
||||
console.warn("I18N.BreakIterator.isBoundary interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramBooleanMock;
|
||||
},
|
||||
}
|
||||
const IndexUtilMock = {
|
||||
getIndexList: function() {
|
||||
console.warn("I18N.IndexUtil.getIndexList interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
addLocale: function(locale) {
|
||||
console.warn("I18N.IndexUtil.addLocale interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
},
|
||||
getIndex: function(text) {
|
||||
console.warn("I18N.IndexUtil.getIndex interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return paramMock.paramStringMock;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { mockWorker } from './worker'
|
||||
import { mockUtil } from './util'
|
||||
import { mockPower } from './power'
|
||||
import { mockIntl } from './intl'
|
||||
import { mockI18N } from './i18n'
|
||||
import { mockRunningLock } from './runningLock'
|
||||
import { mockRpc } from './rpc'
|
||||
import { mockBytrace } from './bytrace'
|
||||
@@ -57,6 +58,8 @@ export function mockRequireNapiFun() {
|
||||
return mockUtil();
|
||||
case "intl":
|
||||
return mockIntl();
|
||||
case "i18n":
|
||||
return mockI18N();
|
||||
case "power":
|
||||
return mockPower();
|
||||
case "runningLock":
|
||||
|
||||
@@ -3,19 +3,34 @@ import { paramMock } from "../utils"
|
||||
export function mockIntl() {
|
||||
const result = {
|
||||
DateTimeFormat: function(...args) {
|
||||
console.warn("url.URLSearchParams interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("Intl.DateTimeFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return DateTimeFormatMock;
|
||||
},
|
||||
NumberFormat: function(...args) {
|
||||
console.warn("url.URL interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("Intl.NumberFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return NumberFormatMoc;
|
||||
return NumberFormatMock;
|
||||
},
|
||||
Locale: function(locale) {
|
||||
console.warn("url.URL interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
console.warn("Intl.Locale interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return LocaleMock;
|
||||
},
|
||||
Collator: function(...args) {
|
||||
console.warn("Intl.Collator interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return CollatorMock;
|
||||
},
|
||||
PluralRules: function(...args) {
|
||||
console.warn("Intl.PluralRules interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return PluralRulesMock;
|
||||
},
|
||||
RelativeTimeFormat: function(...args) {
|
||||
console.warn("Intl.RelativeTimeFormat interface mocked in the Previewer. How this interface works on the Previewer" +
|
||||
" may be different from that on a real device.")
|
||||
return RelativeTimeFormatMock;
|
||||
}
|
||||
}
|
||||
const DateTimeFormatMock = {
|
||||
@@ -35,7 +50,7 @@ export function mockIntl() {
|
||||
return DateTimeOptionsMock;
|
||||
}
|
||||
}
|
||||
const NumberFormatMoc = {
|
||||
const NumberFormatMock = {
|
||||
format: function(number) {
|
||||
console.warn("Intl.NumberFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
@@ -74,6 +89,42 @@ export function mockIntl() {
|
||||
return LocaleMock;
|
||||
}
|
||||
}
|
||||
const CollatorMock = {
|
||||
compare: function(firstString, secondString) {
|
||||
console.warn("Intl.Collator.compare interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramNumberMock;
|
||||
},
|
||||
resolvedOptions: function() {
|
||||
console.warn("Intl.Collator.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return CollatorOptionsMock;
|
||||
}
|
||||
}
|
||||
const PluralRulesMock = {
|
||||
select: function(number) {
|
||||
console.warn("Intl.PluralRules.select 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 RelativeTimeFormatMock = {
|
||||
format: function(value, unit) {
|
||||
console.warn("Intl.RelativeTimeFormat.format interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramStringMock;
|
||||
},
|
||||
formatToParts: function(value, unit) {
|
||||
console.warn("Intl.RelativeTimeFormat.formatToParts interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return paramMock.paramArrayMock;
|
||||
},
|
||||
resolvedOptions: function() {
|
||||
console.warn("Intl.RelativeTimeFormat.resolvedOptions interface mocked in the Previewer. How this interface works on the" +
|
||||
" Previewer may be different from that on a real device.");
|
||||
return RelativeTimeFormatResolvedOptionsMock;
|
||||
}
|
||||
}
|
||||
const DateTimeOptionsMock = {
|
||||
locale: '[PC preview] unknow locale',
|
||||
dateStyle: '[PC preview] unknow dateStyle',
|
||||
@@ -115,5 +166,28 @@ export function mockIntl() {
|
||||
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
|
||||
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
|
||||
}
|
||||
const CollatorOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
usage: '[PC preview] unknow usage',
|
||||
sensitivity: '[PC preview] unknow sensitivity',
|
||||
ignorePunctuation: '[PC preview] unknow ignorePunctuation',
|
||||
collation: '[PC preview] unknow collation',
|
||||
numeric: '[PC preview] unknow numeric',
|
||||
caseFirst: '[PC preview] unknow caseFirst',
|
||||
}
|
||||
const PluralRulesOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
type: '[PC preview] unknow type',
|
||||
minimumIntegerDigits: '[PC preview] unknow minimumIntegerDigits',
|
||||
minimumFractionDigits: '[PC preview] unknow minimumFractionDigits',
|
||||
maximumFractionDigits: '[PC preview] unknow maximumFractionDigits',
|
||||
minimumSignificantDigits: '[PC preview] unknow minimumSignificantDigits',
|
||||
maximumSignificantDigits: '[PC preview] unknow maximumSignificantDigits',
|
||||
}
|
||||
const RelativeTimeFormatResolvedOptionsMock = {
|
||||
localeMatcher: '[PC preview] unknow localeMatcher',
|
||||
numeric: '[PC preview] unknow numeric',
|
||||
style: '[PC preview] unknow style',
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user