@@ -5,13 +5,18 @@ import { vi } from "vitest";
55import "@testing-library/jest-dom" ;
66
77import ModelNav from "../ModelNav" ;
8- import { useRemodels } from "../../../hooks" ;
8+ import { useRemodels , useSerialLogs } from "../../../hooks" ;
99
1010import type { UseQueryResult } from "react-query" ;
11- import type { ApiResponse , RemodelResponse } from "../../../types/shared" ;
11+ import type {
12+ ApiResponse ,
13+ RemodelResponse ,
14+ SerialLogResponse ,
15+ } from "../../../types/shared" ;
1216
1317vi . mock ( "../../../hooks" , ( ) => ( {
1418 useRemodels : vi . fn ( ) ,
19+ useSerialLogs : vi . fn ( ) ,
1520} ) ) ;
1621
1722vi . mock ( "../../../state/brandStoreState" , ( ) => ( {
@@ -47,6 +52,17 @@ describe("ModelNav", () => {
4752 } ,
4853 } as unknown as UseQueryResult < ApiResponse < RemodelResponse > , Error > ) ;
4954
55+ const mockUseSerialLogs = vi . mocked ( useSerialLogs ) ;
56+ mockUseSerialLogs . mockReturnValue ( {
57+ data : {
58+ success : true ,
59+ data : {
60+ items : [ ] ,
61+ "next-cursor" : null ,
62+ } ,
63+ } ,
64+ } as unknown as UseQueryResult < ApiResponse < SerialLogResponse > , Error > ) ;
65+
5066 renderComponent ( "policies" ) ;
5167 const currentLink = screen . getByRole ( "tab" , { name : "Policies" } ) ;
5268 expect ( currentLink . getAttribute ( "aria-selected" ) ) . toBe ( "true" ) ;
@@ -64,6 +80,17 @@ describe("ModelNav", () => {
6480 } ,
6581 } as unknown as UseQueryResult < ApiResponse < RemodelResponse > , Error > ) ;
6682
83+ const mockUseSerialLogs = vi . mocked ( useSerialLogs ) ;
84+ mockUseSerialLogs . mockReturnValue ( {
85+ data : {
86+ success : true ,
87+ data : {
88+ items : [ ] ,
89+ "next-cursor" : null ,
90+ } ,
91+ } ,
92+ } as unknown as UseQueryResult < ApiResponse < SerialLogResponse > , Error > ) ;
93+
6794 renderComponent ( "policies" ) ;
6895 const currentLink = screen . getByRole ( "tab" , { name : "Overview" } ) ;
6996 expect ( currentLink . getAttribute ( "aria-selected" ) ) . toBe ( "false" ) ;
@@ -81,6 +108,17 @@ describe("ModelNav", () => {
81108 } ,
82109 } as unknown as UseQueryResult < ApiResponse < RemodelResponse > , Error > ) ;
83110
111+ const mockUseSerialLogs = vi . mocked ( useSerialLogs ) ;
112+ mockUseSerialLogs . mockReturnValue ( {
113+ data : {
114+ success : true ,
115+ data : {
116+ items : [ ] ,
117+ "next-cursor" : null ,
118+ } ,
119+ } ,
120+ } as unknown as UseQueryResult < ApiResponse < SerialLogResponse > , Error > ) ;
121+
84122 renderComponent ( "overview" ) ;
85123 expect ( screen . getByRole ( "tab" , { name : "Remodel" } ) ) . toBeInTheDocument ( ) ;
86124 } ) ;
@@ -98,6 +136,17 @@ describe("ModelNav", () => {
98136 } ,
99137 } as unknown as UseQueryResult < ApiResponse < RemodelResponse > , Error > ) ;
100138
139+ const mockUseSerialLogs = vi . mocked ( useSerialLogs ) ;
140+ mockUseSerialLogs . mockReturnValue ( {
141+ data : {
142+ success : false ,
143+ data : {
144+ items : [ ] ,
145+ "next-cursor" : null ,
146+ } ,
147+ } ,
148+ } as unknown as UseQueryResult < ApiResponse < SerialLogResponse > , Error > ) ;
149+
101150 renderComponent ( "overview" ) ;
102151 expect (
103152 screen . queryByRole ( "tab" , { name : "Remodel" } ) ,
@@ -110,6 +159,11 @@ describe("ModelNav", () => {
110159 data : undefined ,
111160 } as unknown as UseQueryResult < ApiResponse < RemodelResponse > , Error > ) ;
112161
162+ const mockUseSerialLogs = vi . mocked ( useSerialLogs ) ;
163+ mockUseSerialLogs . mockReturnValue ( {
164+ data : undefined ,
165+ } as unknown as UseQueryResult < ApiResponse < SerialLogResponse > , Error > ) ;
166+
113167 renderComponent ( "overview" ) ;
114168 expect (
115169 screen . queryByRole ( "tab" , { name : "Remodel" } ) ,
0 commit comments