piral-core 0.15.0-alpha.3905 → 0.15.0-alpha.4005

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/esm/components/ExtensionSlot.js +2 -1
  2. package/esm/components/ExtensionSlot.js.map +1 -1
  3. package/esm/modules/element.js +15 -12
  4. package/esm/modules/element.js.map +1 -1
  5. package/esm/utils/media.js +1 -2
  6. package/esm/utils/media.js.map +1 -1
  7. package/lib/components/ExtensionSlot.js +2 -1
  8. package/lib/components/ExtensionSlot.js.map +1 -1
  9. package/lib/modules/element.js +15 -12
  10. package/lib/modules/element.js.map +1 -1
  11. package/lib/utils/media.js +1 -2
  12. package/lib/utils/media.js.map +1 -1
  13. package/package.json +4 -4
  14. package/src/RootListener.test.tsx +45 -0
  15. package/src/actions/app.test.ts +90 -2
  16. package/src/actions/portal.test.ts +53 -8
  17. package/src/components/ExtensionSlot.test.tsx +56 -5
  18. package/src/components/ExtensionSlot.tsx +3 -4
  19. package/src/components/ForeignComponentContainer.test.tsx +119 -0
  20. package/src/components/PiralView-server.test.tsx +60 -0
  21. package/src/components/PiralView.test.tsx +1 -1
  22. package/src/components/PiralView.tsx +1 -1
  23. package/src/components/SwitchErrorInfo.test.tsx +38 -0
  24. package/src/createInstance.test.tsx +10 -0
  25. package/src/hooks/globalState-server.test.ts +41 -0
  26. package/src/hooks/setter-server.test.ts +22 -0
  27. package/src/hooks/setter.test.ts +19 -0
  28. package/src/modules/element-server.test.ts +29 -0
  29. package/src/modules/element.test.ts +77 -0
  30. package/src/modules/element.ts +16 -12
  31. package/src/state/withApi.test.tsx +28 -9
  32. package/src/utils/extension.test.tsx +11 -1
  33. package/src/utils/foreign.test.ts +22 -4
  34. package/src/utils/guid.test.ts +6 -1
  35. package/src/utils/helpers.test.ts +52 -0
  36. package/src/utils/media-server.test.ts +13 -0
  37. package/src/utils/media.ts +1 -2
  38. package/src/utils/state.test.ts +39 -0
@@ -0,0 +1,119 @@
1
+ import * as React from 'react';
2
+ import { render, unmountComponentAtNode } from 'react-dom';
3
+ import { ForeignComponentContainer } from './ForeignComponentContainer';
4
+
5
+ describe('ForeignComponentContainer component', () => {
6
+ it('mounts an HTML component', () => {
7
+ const container = document.body.appendChild(document.createElement('div'));
8
+ const mount = jest.fn();
9
+ const component = { mount };
10
+ render(
11
+ <ForeignComponentContainer $component={component} $context={undefined} $portalId="foo" innerProps={{}} />,
12
+ container,
13
+ );
14
+ expect(mount).toHaveBeenCalled();
15
+ container.remove();
16
+ });
17
+
18
+ it('unmounts an HTML component', () => {
19
+ const container = document.body.appendChild(document.createElement('div'));
20
+ const mount = jest.fn();
21
+ const unmount = jest.fn();
22
+ const component = { mount, unmount };
23
+ render(
24
+ <ForeignComponentContainer $component={component} $context={undefined} $portalId="foo" innerProps={{}} />,
25
+ container,
26
+ );
27
+ expect(mount).toHaveBeenCalled();
28
+ expect(unmount).not.toHaveBeenCalled();
29
+ unmountComponentAtNode(container);
30
+ expect(unmount).toHaveBeenCalled();
31
+ container.remove();
32
+ });
33
+
34
+ it('updates an HTML component', () => {
35
+ const container = document.body.appendChild(document.createElement('div'));
36
+ const mount = jest.fn();
37
+ const update = jest.fn();
38
+ const component = { mount, update };
39
+ render(
40
+ <ForeignComponentContainer
41
+ $component={component}
42
+ $context={undefined}
43
+ $portalId="foo"
44
+ innerProps={{ a: 'bar' }}
45
+ />,
46
+ container,
47
+ );
48
+ expect(mount).toHaveBeenCalled();
49
+ expect(update).not.toHaveBeenCalled();
50
+ render(
51
+ <ForeignComponentContainer
52
+ $component={component}
53
+ $context={undefined}
54
+ $portalId="foo"
55
+ innerProps={{ a: 'foo' }}
56
+ />,
57
+ container,
58
+ );
59
+ expect(update).toHaveBeenCalled();
60
+ container.remove();
61
+ });
62
+
63
+ it('forces re-rendering of an HTML component', () => {
64
+ const container = document.body.appendChild(document.createElement('div'));
65
+ const componentDidMount = ForeignComponentContainer.prototype.componentDidMount;
66
+ ForeignComponentContainer.prototype.componentDidMount = function () {
67
+ componentDidMount.call(this);
68
+ this.previous = {
69
+ removeEventListener() {},
70
+ };
71
+ };
72
+ const mount = jest.fn();
73
+ const update = jest.fn();
74
+ const unmount = jest.fn();
75
+ const component = { mount, update, unmount };
76
+ render(
77
+ <ForeignComponentContainer
78
+ $component={component}
79
+ $context={undefined}
80
+ $portalId="foo"
81
+ innerProps={{ a: 'bar' }}
82
+ />,
83
+ container,
84
+ );
85
+ expect(mount).toHaveBeenCalled();
86
+ expect(unmount).not.toHaveBeenCalled();
87
+ expect(update).not.toHaveBeenCalled();
88
+ render(
89
+ <ForeignComponentContainer
90
+ $component={component}
91
+ $context={undefined}
92
+ $portalId="foo"
93
+ innerProps={{ a: 'foo' }}
94
+ />,
95
+ container,
96
+ );
97
+ expect(update).not.toHaveBeenCalled();
98
+ expect(unmount).toHaveBeenCalled();
99
+ container.remove();
100
+ });
101
+
102
+ it('listens to render-html', () => {
103
+ const container = document.body.appendChild(document.createElement('div'));
104
+ const mount = jest.fn();
105
+ const renderHtmlExtension = jest.fn();
106
+ const component = { mount };
107
+ const props = { piral: { renderHtmlExtension }, meta: {} };
108
+ render(
109
+ <ForeignComponentContainer $component={component} $context={undefined} $portalId="foo" innerProps={props} />,
110
+ container,
111
+ );
112
+ expect(mount).toHaveBeenCalled();
113
+ const node = document.querySelector('[data-portal-id=foo]');
114
+ expect(renderHtmlExtension).not.toHaveBeenCalled();
115
+ node.dispatchEvent(new CustomEvent('render-html', { detail: {} }));
116
+ expect(renderHtmlExtension).toHaveBeenCalled();
117
+ container.remove();
118
+ });
119
+ });
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
5
+ import * as React from 'react';
6
+ import * as hooks from '../hooks';
7
+ import * as routes from './PiralRoutes';
8
+ import { render } from 'enzyme';
9
+ import { PiralView } from './PiralView';
10
+
11
+ const StubDashboard: React.FC = () => <div />;
12
+ StubDashboard.displayName = 'StubDashboard';
13
+
14
+ const StubErrorInfo: React.FC = () => <div />;
15
+ StubErrorInfo.displayName = 'StubErrorInfo';
16
+
17
+ const StubLoader: React.FC = () => <div />;
18
+ StubLoader.displayName = 'StubLoader';
19
+
20
+ const StubRouter: React.FC = ({ children }) => <div>{children}</div>;
21
+ StubRouter.displayName = 'StubRouter';
22
+
23
+ const StubLayout: React.FC = ({ children }) => <div>{children}</div>;
24
+ StubLayout.displayName = 'StubLayout';
25
+
26
+ jest.mock('../hooks');
27
+ jest.mock('./PiralRoutes');
28
+
29
+ const state = {
30
+ app: {
31
+ error: undefined,
32
+ loading: true,
33
+ },
34
+ components: {
35
+ ErrorInfo: StubErrorInfo,
36
+ LoadingIndicator: StubLoader,
37
+ Router: StubRouter,
38
+ Layout: StubLayout,
39
+ },
40
+ registry: {
41
+ pages: {},
42
+ extensions: {},
43
+ },
44
+ routes: {},
45
+ provider: undefined,
46
+ };
47
+
48
+ (hooks as any).useGlobalState = (select: any) => select(state);
49
+
50
+ (routes as any).PiralRoutes = ({ }) => <StubDashboard />;
51
+
52
+ describe('Portal Module', () => {
53
+ it('In this test window should be undefined', () => {
54
+ state.app.loading = false;
55
+ state.app.error = undefined;
56
+ const node = render(<PiralView />);
57
+ expect(typeof window).toBe("undefined")
58
+ expect(node.length).toBe(1);
59
+ });
60
+ });
@@ -43,7 +43,7 @@ const state = {
43
43
 
44
44
  (hooks as any).useGlobalState = (select: any) => select(state);
45
45
 
46
- (routes as any).PiralRoutes = ({}) => <StubDashboard />;
46
+ (routes as any).PiralRoutes = ({ }) => <StubDashboard />;
47
47
 
48
48
  describe('Portal Module', () => {
49
49
  it('renders the dashboard / content in layout if loaded without error', () => {
@@ -42,7 +42,7 @@ const PiralProvider: React.FC = ({ children }) => {
42
42
  /**
43
43
  * The props for the PiralView component.
44
44
  */
45
- export interface PiralViewProps {}
45
+ export interface PiralViewProps { }
46
46
 
47
47
  /**
48
48
  * The component responsible for the generic view of the application.
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import { SwitchErrorInfo } from './SwitchErrorInfo';
4
+
5
+ jest.mock('../hooks/globalState', () => ({
6
+ useGlobalState(select: any) {
7
+ return select(state);
8
+ },
9
+ }));
10
+
11
+ const StubComponent1: React.FC = (props) => <div children={props.children} />;
12
+ const Unknown: React.FC = (props) => <div children={props.children} />;
13
+
14
+ const state = {
15
+ registry: {
16
+ extensions: {},
17
+ },
18
+ errorComponents: {
19
+ stubComponent1: StubComponent1,
20
+ unknown: Unknown,
21
+ },
22
+ };
23
+
24
+ (React as any).useMemo = (cb) => cb();
25
+
26
+ describe('SwitchErrorInfo Module', () => {
27
+ it('is able to render StubComponent1 component', () => {
28
+ const node = mount(<SwitchErrorInfo type="stubComponent1" />);
29
+ expect(node.at(0).exists()).toBe(true);
30
+ expect(node.find(StubComponent1).length).toBe(1);
31
+ });
32
+
33
+ it('is able to default render Unknow component if the compenent name not available in state data', () => {
34
+ const node = mount(<SwitchErrorInfo type="notRealComponent" />);
35
+ expect(node.at(0).exists()).toBe(true);
36
+ expect(node.find(Unknown).length).toBe(1);
37
+ });
38
+ })
@@ -11,4 +11,14 @@ describe('Piral-Core createInstance module', () => {
11
11
  const instance = createInstance({ async: true });
12
12
  expect(instance.options.strategy).toBe(blazingStrategy);
13
13
  });
14
+
15
+ it('createInstance with empty actions and plugins uses the standard strategy', () => {
16
+ const instance = createInstance({ plugins: {}, actions: {} });
17
+ expect(instance.options.strategy).toBe(standardStrategy);
18
+ })
19
+
20
+ it('createInstance with async function uses the blazing strategy', () => {
21
+ const instance = createInstance({ async: () => { } });
22
+ expect(instance.options.strategy).not.toBe(blazingStrategy);
23
+ })
14
24
  });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+ import { useGlobalState } from './globalState';
5
+
6
+ jest.mock('react', () => {
7
+ const { Atom } = require('@libre/atom');
8
+ const state = Atom.of({
9
+ foo: 5,
10
+ bar: {
11
+ qxz: 'hello',
12
+ },
13
+ list: [1, 2, 3],
14
+ });
15
+ return {
16
+ createContext: jest.fn(),
17
+ useContext: () => ({ state }),
18
+ useState: (v) => [v, jest.fn()],
19
+ useMemo: (f) => f(),
20
+ useLayoutEffect: (f) => f(),
21
+ };
22
+ });
23
+
24
+ describe('Media Module', () => {
25
+ it('in here window should be undefined', () => {
26
+ expect(typeof window).toBe('undefined');
27
+ const result = useGlobalState((m) => (m as any).foo);
28
+ expect(result).toBe(5);
29
+ });
30
+
31
+ it('gets full state object', () => {
32
+ const result = useGlobalState();
33
+ expect(result).toEqual({
34
+ foo: 5,
35
+ bar: {
36
+ qxz: 'hello',
37
+ },
38
+ list: [1, 2, 3],
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
5
+ import * as React from 'react';
6
+ import { renderToString } from 'react-dom/server';
7
+ import { useSetter } from './setter';
8
+
9
+ describe('UseSetter Hook Module', () => {
10
+ it('UseSetter', () => {
11
+ const cb = jest.fn();
12
+
13
+ const MyComponent = () => {
14
+ useSetter(cb);
15
+ return null;
16
+ };
17
+
18
+ const result = renderToString(React.createElement(MyComponent));
19
+ expect(result).toEqual('');
20
+ expect(cb).toHaveBeenCalled();
21
+ });
22
+ });
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { act } from 'react-dom/test-utils';
3
+ import { render } from 'react-dom';
4
+ import { useSetter } from './setter';
5
+
6
+ describe('UseSetter Hook Module', () => {
7
+ it('UseSetter', async () => {
8
+ const cb = jest.fn();
9
+
10
+ const MyComponent = () => {
11
+ useSetter(cb);
12
+ return null;
13
+ };
14
+
15
+ render(React.createElement(MyComponent), document.body.appendChild(document.createElement('div')));
16
+ await act(() => Promise.resolve());
17
+ expect(cb).toHaveBeenCalled();
18
+ });
19
+ });
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+
5
+ import { Atom, deref } from '@dbeining/react-atom';
6
+ import { createListener } from 'piral-base';
7
+ import { createActions } from '../state';
8
+ import { renderElement } from './element';
9
+
10
+ function createMockContext(): [any, any] {
11
+ const state = Atom.of({
12
+ portals: {
13
+ root: [],
14
+ },
15
+ });
16
+ const context = createActions(state, createListener({}));
17
+ return [context, state];
18
+ }
19
+
20
+ describe('Elements Module from SSR', () => {
21
+ it('Should not have piral-extensions web component', () => {
22
+ const [context, state] = createMockContext();
23
+ const element: any = {
24
+ addEventListener() {},
25
+ };
26
+ renderElement(context, element, {});
27
+ expect(deref(state)['portals']['root'].length).toBe(0);
28
+ });
29
+ });
@@ -0,0 +1,77 @@
1
+ import { Atom, deref } from '@dbeining/react-atom';
2
+ import { createListener } from 'piral-base';
3
+ import { createActions } from '../state';
4
+ import { renderElement } from './element';
5
+
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ "piral-extension": HTMLElement & {
9
+ params: any;
10
+ name: string;
11
+ empty: any;
12
+ };
13
+ }
14
+ }
15
+
16
+ function createMockContext(): [any, any] {
17
+ const state = Atom.of({
18
+ portals: {},
19
+ });
20
+ const context = createActions(state, createListener({}));
21
+ return [context, state];
22
+ }
23
+
24
+ describe('Elements Module', () => {
25
+ it('testing basic renderElement functionality of piral-extension web component', () => {
26
+ const [context, state] = createMockContext();
27
+ const element = document.createElement('piral-extension');
28
+ const event = new Event('extension-props-changed');
29
+ document.body.appendChild(element);
30
+ renderElement(context, element, {});
31
+ element.dispatchEvent(event);
32
+ document.body.removeChild(element);
33
+ (element as any).connectedCallback();
34
+ expect(deref(state)['portals']['root'].length).toBe(1);
35
+ });
36
+
37
+ it('disposing piral-extension web component', () => {
38
+ const [context, state] = createMockContext();
39
+ const element = document.createElement('piral-extension');
40
+ document.body.appendChild(element);
41
+ const [dispose] = renderElement(context, element, {});
42
+ expect(deref(state)['portals']['root'].length).toBe(1);
43
+ dispose();
44
+ expect(deref(state)['portals']['root'].length).toBe(0);
45
+ });
46
+
47
+ it('testing setters and getters in piral-extension web component', () => {
48
+ const [context] = createMockContext();
49
+ const element = document.createElement('piral-extension');
50
+ document.body.appendChild(element);
51
+ renderElement(context, element, {});
52
+ expect(element.params).toEqual(null);
53
+ expect(element.name).toEqual(null);
54
+ expect(element.empty).toEqual(undefined);
55
+ element.params = 'anything';
56
+ element.name = 'foo';
57
+ element.empty = 'anything';
58
+ expect(element.params).toEqual('anything');
59
+ expect(element.name).toEqual('foo');
60
+ expect(element.empty).toEqual('anything');
61
+ element.setAttribute('name', 'bar');
62
+ element.setAttribute('params', '{}');
63
+ expect(element.params).toEqual({});
64
+ expect(element.name).toEqual('bar');
65
+ });
66
+
67
+ it('testing attributes of piral-extension web component', () => {
68
+ const [context] = createMockContext();
69
+ const element = document.createElement('piral-extension');
70
+ document.body.appendChild(element);
71
+ renderElement(context, element, {});
72
+ element.setAttribute('name', 'bar');
73
+ element.setAttribute('params', '{}');
74
+ expect(element.params).toEqual({});
75
+ expect(element.name).toEqual('bar');
76
+ });
77
+ });
@@ -88,16 +88,20 @@ export function renderElement(
88
88
  element: HTMLElement | ShadowRoot,
89
89
  props: any,
90
90
  ): [Disposable, Updatable] {
91
- let [id, portal] = renderInDom(context, element, ExtensionSlot, props);
92
- const evName = 'extension-props-changed';
93
- const handler = (ev: CustomEvent) => update(ev.detail);
94
- const dispose: Disposable = () => {
95
- context.hidePortal(id, portal);
96
- element.removeEventListener(evName, handler);
97
- };
98
- const update: Updatable = (newProps) => {
99
- [id, portal] = changeDomPortal(id, portal, context, element, ExtensionSlot, newProps);
100
- };
101
- element.addEventListener(evName, handler);
102
- return [dispose, update];
91
+ if (typeof window !== 'undefined') {
92
+ let [id, portal] = renderInDom(context, element, ExtensionSlot, props);
93
+ const evName = 'extension-props-changed';
94
+ const handler = (ev: CustomEvent) => update(ev.detail);
95
+ const dispose: Disposable = () => {
96
+ context.hidePortal(id, portal);
97
+ element.removeEventListener(evName, handler);
98
+ };
99
+ const update: Updatable = (newProps) => {
100
+ [id, portal] = changeDomPortal(id, portal, context, element, ExtensionSlot, newProps);
101
+ };
102
+ element.addEventListener(evName, handler);
103
+ return [dispose, update];
104
+ }
105
+
106
+ return [noop, noop];
103
107
  }
@@ -6,6 +6,29 @@ import { withApi } from './withApi';
6
6
  import { StateContext } from '../state';
7
7
 
8
8
  function createMockContainer() {
9
+ const state = Atom.of({
10
+ portals: {},
11
+ });
12
+ return {
13
+ context: {
14
+ converters: {},
15
+ readState(cb) {
16
+ return cb({
17
+ registry: {
18
+ wrappers: { "feed": "test", "*": "test" },
19
+ },
20
+ });
21
+ },
22
+ on: jest.fn(),
23
+ off: jest.fn(),
24
+ emit: jest.fn(),
25
+ state,
26
+ destroyPortal: (id) => { },
27
+ } as any,
28
+ };
29
+ }
30
+
31
+ function createMockContainerWithNoWrappers() {
9
32
  const state = Atom.of({
10
33
  portals: {},
11
34
  });
@@ -23,7 +46,7 @@ function createMockContainer() {
23
46
  off: jest.fn(),
24
47
  emit: jest.fn(),
25
48
  state,
26
- destroyPortal: (id) => {},
49
+ destroyPortal: (id) => { },
27
50
  } as any,
28
51
  };
29
52
  }
@@ -103,11 +126,9 @@ describe('withApi Module', () => {
103
126
  };
104
127
  const { context } = createMockContainer();
105
128
  context.converters = {
106
- html: (component) => {
107
- return component.component;
108
- },
129
+ html: ({ component }) => component,
109
130
  };
110
- const Component = withApi(context, { type: 'html', component: { mount: () => {} } }, api, 'unknown');
131
+ const Component = withApi(context, { type: 'html', component: { mount: () => { } } }, api, 'unknown');
111
132
 
112
133
  const node = mount(
113
134
  <StateContext.Provider value={context}>
@@ -124,11 +145,9 @@ describe('withApi Module', () => {
124
145
  name: 'foo',
125
146
  },
126
147
  };
127
- const { context } = createMockContainer();
148
+ const { context } = createMockContainerWithNoWrappers();
128
149
  context.converters = {
129
- html: (component) => {
130
- return component.component;
131
- },
150
+ html: ({ component }) => component,
132
151
  };
133
152
  const Component = withApi(context, null, api, 'unknown');
134
153
 
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { mount } from 'enzyme';
3
- import { toExtension } from './extension';
3
+ import { reactifyContent, toExtension } from './extension';
4
+
4
5
 
5
6
  describe('Util Extension.', () => {
6
7
  it('Convert some component to an extension component.', () => {
@@ -9,4 +10,13 @@ describe('Util Extension.', () => {
9
10
  const node = mount(<Extension piral={undefined} params={{ title: 'Foo' }} />);
10
11
  expect(node.find('b').length).toBe(1);
11
12
  });
13
+
14
+ it('reactifyContent.', async () => {
15
+ const container = document.body.appendChild(document.createElement('div'));
16
+ container.innerHTML = `<div>FOO<</div>`;
17
+ const result = reactifyContent(container.childNodes) as React.ReactElement;
18
+ const node = await mount(result)
19
+ expect(node.find("slot").length).toBe(1);
20
+ });
12
21
  });
22
+
@@ -1,12 +1,30 @@
1
- import { createElement } from 'react';
2
- import { convertComponent, renderInDom } from './foreign';
1
+ import * as React from 'react';
2
+ import { changeDomPortal, convertComponent, renderInDom } from './foreign';
3
3
  import { ForeignComponent } from '../types';
4
4
  import { DefaultLoadingIndicator } from '../components/DefaultLoader';
5
5
 
6
+ // const StubComponent: React.FC = (props) => <div />;
7
+ // StubComponent.displayName = 'StubComponent';
8
+
6
9
  describe('Util Foreign.', () => {
10
+ it('changeDomPortal changes dom in portal', () => {
11
+ const children = React.createElement('div');
12
+ const current: React.ReactPortal = { key: 'current', children: { children }, type: 'div', props: null };
13
+
14
+ const context = {
15
+ updatePortal: jest.fn(),
16
+ } as any;
17
+ const portalId = 'data-portal-id';
18
+ const element = document.createElement('div') as HTMLDivElement;
19
+ element.setAttribute(portalId, '100');
20
+
21
+ const result = changeDomPortal(portalId, current, context, element, DefaultLoadingIndicator, {});
22
+ expect(result).not.toEqual({});
23
+ });
24
+
7
25
  it('Convert component function throws error due to missing converter function.', () => {
8
26
  const t = () => {
9
- convertComponent(null, createElement('div'));
27
+ convertComponent(null, React.createElement('div'));
10
28
  };
11
29
  expect(t).toThrow('No converter for component of type "div" registered.');
12
30
  });
@@ -17,7 +35,7 @@ describe('Util Foreign.', () => {
17
35
  };
18
36
  const result = convertComponent(() => {
19
37
  return fComponent;
20
- }, createElement('div'));
38
+ }, React.createElement('div'));
21
39
  expect(result).toEqual(fComponent);
22
40
  });
23
41
 
@@ -1,6 +1,11 @@
1
- import { generateId } from './guid';
1
+ import { buildName, generateId } from './guid';
2
2
 
3
3
  describe('Guid Utility Module', () => {
4
+ it('buildName returns name with its prefix', () => {
5
+ const result = buildName('Ma', 'Majd');
6
+ expect(result).toEqual('Ma://Majd');
7
+ });
8
+
4
9
  it('Generates two consecutive different guids', () => {
5
10
  const guid1 = generateId();
6
11
  const guid2 = generateId();