Skip to content

Commit

Permalink
Address CR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba committed Sep 9, 2021
1 parent 18d507c commit 8ee5104
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ const idToUrlMap = {
type IdKey = keyof typeof idToUrlMap;

const stringifySearchParams = (params: Record<string, any>) => {
return Object.keys(params).reduce((list, key) => {
const stringifiedParams = Object.keys(params).reduce((list, key) => {
const value = typeof params[key] === 'object' ? JSON.stringify(params[key]) : params[key];

return { ...list, [key]: value };
}, {});

return new URLSearchParams(stringifiedParams).toString();
};

const shareMock = sharePluginMock.createSetupContract();
// @ts-expect-error This object is missing some properties that we're not using in the UI
shareMock.url.locators.get = (id: IdKey) => ({
useUrl: (): string | undefined => idToUrlMap[id],
getUrl: (params: Record<string, any>): string | undefined =>
`${idToUrlMap[id]}?${new URLSearchParams(stringifySearchParams(params)).toString()}`,
`${idToUrlMap[id]}?${stringifySearchParams(params)}`,
});

export const getAppContextMock = () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/


import React, { FunctionComponent, useEffect } from 'react';
import moment from 'moment-timezone';
import { FormattedDate, FormattedTime, FormattedMessage } from '@kbn/i18n/react';
Expand Down

0 comments on commit 8ee5104

Please sign in to comment.