@@ -4,8 +4,6 @@ import { render, screen } from '@testing-library/react';
4
4
import '@testing-library/jest-dom/extend-expect' ;
5
5
import LeftSidebar from './LeftSidebar' ;
6
6
import { useLayoutContext } from 'src/contexts/layout-context' ;
7
- import { NavProduct } from 'src/data/nav/types' ;
8
- import { ProductKey } from 'src/data/types' ;
9
7
10
8
jest . mock ( 'src/contexts/layout-context' , ( ) => ( {
11
9
useLayoutContext : jest . fn ( ) ,
@@ -25,57 +23,58 @@ jest.mock('../Link', () => {
25
23
return MockLink ;
26
24
} ) ;
27
25
28
- const mockUseLayoutContext = useLayoutContext as jest . Mock ;
29
- const mockUseLocation = useLocation as jest . Mock ;
30
-
31
- const mockProducts : [ ProductKey , NavProduct ] [ ] = [
32
- [
33
- 'platform' ,
34
- {
35
- name : 'Platform' ,
36
- icon : { open : 'icon-gui-chevron-up-micro' , closed : 'icon-gui-chevron-down-micro' } ,
37
- content : [
38
- {
39
- name : 'Overview' ,
40
- pages : [
41
- { name : 'Introduction' , link : '/platform/intro' } ,
42
- { name : 'Getting Started' , link : '/platform/getting-started' } ,
43
- ] ,
44
- } ,
45
- ] ,
46
- api : [
47
- {
48
- name : 'API Overview' ,
49
- pages : [
50
- { name : 'API Introduction' , link : '/platform/api-intro' } ,
51
- { name : 'API Reference' , link : '/platform/api-reference' } ,
52
- ] ,
53
- } ,
54
- ] ,
55
- link : '/platform' ,
56
- showJumpLink : true ,
26
+ // Mock productData
27
+ jest . mock ( 'src/data' , ( ) => ( {
28
+ productData : {
29
+ platform : {
30
+ nav : {
31
+ name : 'Platform' ,
32
+ icon : { open : 'icon-gui-chevron-up-micro' , closed : 'icon-gui-chevron-down-micro' } ,
33
+ content : [
34
+ {
35
+ name : 'Overview' ,
36
+ pages : [
37
+ { name : 'Introduction' , link : '/platform/intro' } ,
38
+ { name : 'Getting Started' , link : '/platform/getting-started' } ,
39
+ ] ,
40
+ } ,
41
+ ] ,
42
+ api : [
43
+ {
44
+ name : 'API Overview' ,
45
+ pages : [
46
+ { name : 'API Introduction' , link : '/platform/api-intro' } ,
47
+ { name : 'API Reference' , link : '/platform/api-reference' } ,
48
+ ] ,
49
+ } ,
50
+ ] ,
51
+ link : '/platform' ,
52
+ showJumpLink : true ,
53
+ } ,
57
54
} ,
58
- ] ,
59
- [
60
- 'pubsub' ,
61
- {
62
- name : 'Pub/Sub' ,
63
- icon : { open : 'icon-gui-chevron-up-outline' , closed : 'icon-gui-chevron-down-outline' } ,
64
- content : [
65
- {
66
- name : 'Overview' ,
67
- pages : [
68
- { name : 'Introduction' , link : '/pubsub/intro' } ,
69
- { name : 'Getting Started' , link : '/pubsub/getting-started' } ,
70
- ] ,
71
- } ,
72
- ] ,
73
- api : [ ] ,
74
- link : '/pubsub' ,
75
- showJumpLink : false ,
55
+ pubsub : {
56
+ nav : {
57
+ name : 'Pub/Sub' ,
58
+ icon : { open : 'icon-gui-chevron-up-outline' , closed : 'icon-gui-chevron-down-outline' } ,
59
+ content : [
60
+ {
61
+ name : 'Overview' ,
62
+ pages : [
63
+ { name : 'Introduction' , link : '/pubsub/intro' } ,
64
+ { name : 'Getting Started' , link : '/pubsub/getting-started' } ,
65
+ ] ,
66
+ } ,
67
+ ] ,
68
+ api : [ ] ,
69
+ link : '/pubsub' ,
70
+ showJumpLink : false ,
71
+ } ,
76
72
} ,
77
- ] ,
78
- ] ;
73
+ } ,
74
+ } ) ) ;
75
+
76
+ const mockUseLayoutContext = useLayoutContext as jest . Mock ;
77
+ const mockUseLocation = useLocation as jest . Mock ;
79
78
80
79
describe ( 'LeftSidebar' , ( ) => {
81
80
beforeEach ( ( ) => {
@@ -86,7 +85,6 @@ describe('LeftSidebar', () => {
86
85
{ index : 1 , page : { name : 'Link 2' , link : '/link-2' } } ,
87
86
] ,
88
87
} ,
89
- products : mockProducts ,
90
88
} ) ;
91
89
92
90
mockUseLocation . mockReturnValue ( {
0 commit comments