@axinom/mosaic-ui 0.44.0-rc.1 → 0.44.0-rc.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.44.0-rc.1",
3
+ "version": "0.44.0-rc.2",
4
4
  "description": "UI components for building Axinom Mosaic applications",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -32,7 +32,7 @@
32
32
  "build-storybook": "storybook build"
33
33
  },
34
34
  "dependencies": {
35
- "@axinom/mosaic-core": "^0.4.17-rc.1",
35
+ "@axinom/mosaic-core": "^0.4.17-rc.2",
36
36
  "@faker-js/faker": "^7.4.0",
37
37
  "@popperjs/core": "^2.11.8",
38
38
  "clsx": "^1.1.0",
@@ -105,5 +105,5 @@
105
105
  "publishConfig": {
106
106
  "access": "public"
107
107
  },
108
- "gitHead": "a59e7ea3b1d1ee3427e6553c097ae6e29df14353"
108
+ "gitHead": "dcf763ea92712ac3e3c7056fbad9cfc603bf7246"
109
109
  }
@@ -5,8 +5,6 @@ import { PageHeader } from '../PageHeader';
5
5
  import { StationError } from '../models';
6
6
  import { EmptyStation, EmptyStationProps } from './EmptyStation';
7
7
 
8
- jest.mock('../../hooks/useTabTitle/useTabTitle');
9
-
10
8
  describe('EmptyStation', () => {
11
9
  const defaultProps: EmptyStationProps = {
12
10
  title: 'test-title',
@@ -34,8 +34,6 @@ import {
34
34
  } from './Explorer.model';
35
35
  import { StationMessage } from './useStationMessage';
36
36
 
37
- jest.mock('../../hooks/useTabTitle/useTabTitle');
38
-
39
37
  interface ExplorerTestData {
40
38
  id: number;
41
39
  title: string;
@@ -12,8 +12,6 @@ import { Explorer } from '../Explorer';
12
12
  import { ExplorerDataProvider } from '../Explorer.model';
13
13
  import { NavigationExplorer } from './NavigationExplorer';
14
14
 
15
- jest.mock('../../../hooks/useTabTitle/useTabTitle');
16
-
17
15
  interface NavExplorerTestData {
18
16
  id: string;
19
17
  desc: string;
@@ -11,8 +11,6 @@ import { Explorer } from '../Explorer';
11
11
  import { ExplorerDataProvider } from '../Explorer.model';
12
12
  import { SelectionExplorer } from './SelectionExplorer';
13
13
 
14
- jest.mock('../../../hooks/useTabTitle/useTabTitle');
15
-
16
14
  interface SelectExplorerTestData {
17
15
  id: string;
18
16
  desc: string;
@@ -81,4 +81,15 @@ describe('useTabTitle', () => {
81
81
 
82
82
  expect(setTitle).toHaveBeenCalledTimes(1);
83
83
  });
84
+
85
+ it('should set the tab title outside a react router context', () => {
86
+ (useHistory as jest.Mock) = jest.fn().mockReturnValue(undefined);
87
+
88
+ const title = 'Test Title';
89
+ const setTabTitle = true;
90
+
91
+ mount(<TestWrapper title={title} setTabTitle={setTabTitle} />);
92
+
93
+ expect(setTitle).toHaveBeenCalled();
94
+ });
84
95
  });
@@ -6,10 +6,11 @@ export const useTabTitle = (
6
6
  title: string | undefined,
7
7
  setTabTitle: boolean | undefined,
8
8
  ): void => {
9
- const { location: currentLocation } = useHistory();
10
- const [initialLocation] = useState(currentLocation);
9
+ // useTabTitle should work outside a react router context
10
+ const { location } = useHistory() ?? {};
11
+ const [initialLocation] = useState(location);
11
12
 
12
- if (setTabTitle && currentLocation.pathname === initialLocation.pathname) {
13
+ if (setTabTitle && location?.pathname === initialLocation?.pathname) {
13
14
  setTitle(title);
14
15
  }
15
16
  };