@@ -37,19 +37,6 @@ const defaultMutationMock = {
3737 error : null
3838} ;
3939
40- type ResourceOptions = { name ?: string ; selector ?: { matchLabels ?: Record < string , string > } } ;
41-
42- const loadedResourceMock = ( resourceName : string ) => ( options : ResourceOptions ) => {
43- if ( options . name === resourceName ) {
44- return [ { spec : { host : 'example.com' , port : { targetPort : '8080' } } } , false , undefined ] ;
45- }
46- if ( options . selector ?. matchLabels ?. [ 'app.kubernetes.io/name' ] === 'network-observer' ) {
47- return [ { status : { phase : 'Running' } } , false , undefined ] ;
48- }
49-
50- return [ undefined , false , undefined ] ;
51- } ;
52-
5340const BUTTON_LABELS = {
5441 deploy : 'Deploy the Network Console' ,
5542 open : 'Open the Network Console' ,
@@ -72,15 +59,6 @@ describe('DeploymentNetworkConsoleButton', () => {
7259 expect ( screen . getByText ( BUTTON_LABELS . deploy ) ) . toBeInTheDocument ( ) ;
7360 } ) ;
7461
75- it ( 'renders the open and delete buttons when loaded' , ( ) => {
76- mockUseK8sWatchResource . mockImplementation ( loadedResourceMock ( 'network-observer' ) ) ;
77- mockUseMutationImpl . mockReturnValue ( defaultMutationMock ) ;
78-
79- render ( < DeploymentNetworkConsoleButton /> ) ;
80- expect ( screen . getByText ( BUTTON_LABELS . open ) ) . toBeInTheDocument ( ) ;
81- expect ( screen . getByText ( BUTTON_LABELS . delete ) ) . toBeInTheDocument ( ) ;
82- } ) ;
83-
8462 it ( 'calls the create mutation when the deploy button is clicked' , ( ) => {
8563 const mutateMock = vi . fn ( ) ;
8664 mockUseK8sWatchResource . mockReturnValue ( [ undefined , false , undefined ] ) ;
@@ -90,30 +68,4 @@ describe('DeploymentNetworkConsoleButton', () => {
9068 fireEvent . click ( screen . getByText ( BUTTON_LABELS . deploy ) ) ;
9169 expect ( mutateMock ) . toHaveBeenCalled ( ) ;
9270 } ) ;
93-
94- it ( 'calls the delete mutation when the delete button is clicked and calls onSuccess' , ( ) => {
95- const mutateMock = vi . fn ( ) ;
96- let onSuccessCallback : ( ( ) => void ) | undefined ;
97-
98- mockUseK8sWatchResource . mockImplementation ( loadedResourceMock ( 'network-observer' ) ) ;
99- mockUseMutationImpl . mockImplementation ( ( { onSuccess } ) => {
100- onSuccessCallback = onSuccess ;
101-
102- return { ...defaultMutationMock , mutate : mutateMock } ;
103- } ) ;
104-
105- render ( < DeploymentNetworkConsoleButton /> ) ;
106- fireEvent . click ( screen . getByText ( BUTTON_LABELS . delete ) ) ;
107- expect ( mutateMock ) . toHaveBeenCalled ( ) ;
108-
109- onSuccessCallback ?.( ) ;
110- } ) ;
111-
112- it ( 'updates URL when route data changes' , ( ) => {
113- mockUseK8sWatchResource . mockImplementation ( loadedResourceMock ( 'network-observer' ) ) ;
114- mockUseMutationImpl . mockReturnValue ( defaultMutationMock ) ;
115-
116- render ( < DeploymentNetworkConsoleButton /> ) ;
117- expect ( screen . getByText ( BUTTON_LABELS . open ) ) . toBeInTheDocument ( ) ;
118- } ) ;
11971} ) ;
0 commit comments