Skip to content
This repository was archived by the owner on Sep 30, 2020. It is now read-only.

feat: Adds missing mocks for Liferay built-ins #417

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion packages/liferay-npm-scripts/src/jest/mocks/Liferay.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ const Language = {
get: jest.fn(key => key),
};

/**
* Portlet keys injected by the common theme, in:
* https://github.com/liferay/liferay-portal/blob/b36c159f531ba88c4dbff83bbacdfa9d0252f1ae/portal-web/docroot/html/common/themes/top_js.jspf#L135
*/
const PortletKeys = {
DOCUMENT_LIBRARY: 'DOCUMENT_LIBRARY',
DYNAMIC_DATA_MAPPING: 'DYNAMIC_DATA_MAPPING',
ITEM_SELECTOR: 'ITEM_SELECTOR',
};

/**
* https://github.com/liferay/liferay-portal/blob/a4866af62eb89c69ee00d0e69dbe7ff092b50048/modules/apps/frontend-js/frontend-js-web/src/main/resources/META-INF/resources/liferay/global.es.js#L101-L104
*/
Expand Down Expand Up @@ -83,6 +93,18 @@ const ThemeDisplay = {
*/
getDoAsUserIdEncoded: jest.fn(() => 'default-mocked-do-as-user-id'),

/**
* https://github.com/liferay/liferay-portal/blob/31073fb75fb0d3b309f9e0f921cb7a469aa2703d/portal-web/docroot/html/common/themes/top_js.jspf#L164
*/
getLayoutRelativeControlPanelURL: jest.fn(
() => 'layoutRelativeControlPanelURL'
),

/**
* https://github.com/liferay/liferay-portal/blob/31073fb75fb0d3b309f9e0f921cb7a469aa2703d/portal-web/docroot/html/common/themes/top_js.jspf#L168
*/
getLayoutRelativeURL: jest.fn(() => 'layoutRelativeURL'),

/**
* https://github.com/liferay/liferay-portal/blob/a4866af62eb89c69ee00d0e69dbe7ff092b50048/portal-web/docroot/html/common/themes/top_js.jspf#L220
*/
Expand All @@ -107,6 +129,11 @@ const ThemeDisplay = {
* https://github.com/liferay/liferay-portal/blob/31073fb75fb0d3b309f9e0f921cb7a469aa2703d/portal-web/docroot/html/common/themes/top_js.jspf#L247
*/
getPortalURL: jest.fn(() => 'http://localhost:8080'),

/**
* https://github.com/liferay/liferay-portal/blob/31073fb75fb0d3b309f9e0f921cb7a469aa2703d/portal-web/docroot/html/common/themes/top_js.jspf#L250
*/
getScopeGroupId: jest.fn(() => 'scopeGroupId'),
};

/**
Expand Down Expand Up @@ -144,9 +171,10 @@ const Util = {

module.exports = {
...events,
authToken,
Language,
PortletKeys,
Session,
ThemeDisplay,
Util,
authToken,
};