Skip to content

Commit

Permalink
Fix karma tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed May 14, 2020
1 parent ab6aaf3 commit 54a961e
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/legacy/ui/public/new_platform/new_platform.karma_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,31 @@ let isTimeRangeSelectorEnabled = true;
let isAutoRefreshSelectorEnabled = true;

export const mockUiSettings = {
get: item => {
return mockUiSettings[item];
get: (item, defaultValue) => {
const defaultValues = {
dateFormat: 'MMM D, YYYY @ HH:mm:ss.SSS',
'dateFormat:tz': 'UTC',
'shortDots:enable': true,
'courier:ignoreFilterIfFieldNotInIndex': true,
'query:allowLeadingWildcards': true,
'query:queryString:options': {},
'format:currency:defaultPattern': '($0,0.[00])',
'format:number:defaultPattern': '0,0.[000]',
'format:percent:defaultPattern': '0,0.[000]%',
'format:number:defaultLocale': 'en',
'format:defaultTypeMap': {},
'csv:separator': ',',
'csv:quoteValues': true,
'search:queryLanguage': 'kuery',
'state:storeInSessionStorage': false,
};

return defaultValues[item] || defaultValue;
},
getUpdate$: () => ({
subscribe: sinon.fake(),
}),
isDefault: sinon.fake(),
'query:allowLeadingWildcards': true,
'query:queryString:options': {},
'courier:ignoreFilterIfFieldNotInIndex': true,
'dateFormat:tz': 'Browser',
'format:defaultTypeMap': {},
};

const mockCoreSetup = {
Expand Down Expand Up @@ -524,6 +537,8 @@ export function __setup__(coreSetup) {
// bootstrap an LP plugin outside of tests)
npSetup.core.application.register = () => {};

npSetup.core.uiSettings.get = mockUiSettings.get;

// Services that need to be set in the legacy platform since the legacy data
// & vis plugins which previously provided them have been removed.
setSetupServices(npSetup);
Expand All @@ -532,6 +547,8 @@ export function __setup__(coreSetup) {
export function __start__(coreStart) {
npStart.core = coreStart;

npStart.core.uiSettings.get = mockUiSettings.get;

// Services that need to be set in the legacy platform since the legacy data
// & vis plugins which previously provided them have been removed.
setStartServices(npStart);
Expand Down

0 comments on commit 54a961e

Please sign in to comment.