@@ -4,8 +4,6 @@ import { render, screen } from '@testing-library/react';
44import '@testing-library/jest-dom/extend-expect' ;
55import LeftSidebar from './LeftSidebar' ;
66import { useLayoutContext } from 'src/contexts/layout-context' ;
7- import { NavProduct } from 'src/data/nav/types' ;
8- import { ProductKey } from 'src/data/types' ;
97
108jest . mock ( 'src/contexts/layout-context' , ( ) => ( {
119 useLayoutContext : jest . fn ( ) ,
@@ -25,57 +23,58 @@ jest.mock('../Link', () => {
2523 return MockLink ;
2624} ) ;
2725
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+ } ,
5754 } ,
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+ } ,
7672 } ,
77- ] ,
78- ] ;
73+ } ,
74+ } ) ) ;
75+
76+ const mockUseLayoutContext = useLayoutContext as jest . Mock ;
77+ const mockUseLocation = useLocation as jest . Mock ;
7978
8079describe ( 'LeftSidebar' , ( ) => {
8180 beforeEach ( ( ) => {
@@ -86,7 +85,6 @@ describe('LeftSidebar', () => {
8685 { index : 1 , page : { name : 'Link 2' , link : '/link-2' } } ,
8786 ] ,
8887 } ,
89- products : mockProducts ,
9088 } ) ;
9189
9290 mockUseLocation . mockReturnValue ( {
0 commit comments