@@ -8,48 +8,38 @@ import {
8
8
} from "@app/test-config/test-utils" ;
9
9
10
10
import { Proxies } from "../proxies" ;
11
- import MockAdapter from "axios-mock-adapter" ;
12
- import { IDENTITIES , PROXIES } from "@app/api/rest" ;
13
- import axios from "axios" ;
14
- import { Proxy , Identity } from "@app/api/models" ;
15
11
import userEvent from "@testing-library/user-event" ;
16
- import { ProxyForm } from "../proxy-form" ;
17
- import mock from "@app/test-config/mockInstance" ;
18
-
19
- const identitiesData : Identity [ ] = [ ] ;
20
- mock . onGet ( `${ IDENTITIES } ` ) . reply ( 200 , identitiesData ) ;
21
-
22
- const proxiesData = [
23
- {
24
- host : "" ,
25
- kind : "http" ,
26
- port : 0 ,
27
- excluded : [ ] ,
28
- identity : null ,
29
- id : 1 ,
30
- enabled : false ,
31
- } ,
32
- {
33
- host : "" ,
34
- kind : "https" ,
35
- port : 0 ,
36
- excluded : [ ] ,
37
- identity : null ,
38
- id : 1 ,
39
- enabled : false ,
40
- } ,
41
- ] ;
42
- mock . onGet ( `${ PROXIES } ` ) . reply ( 200 , proxiesData ) ;
12
+ import { server } from "@mocks/server" ;
13
+ import { rest } from "msw" ;
43
14
44
15
describe ( "Component: proxy-form" , ( ) => {
16
+ beforeEach ( ( ) => {
17
+ jest . clearAllMocks ( ) ;
18
+ } ) ;
19
+ afterEach ( ( ) => {
20
+ server . resetHandlers ( ) ;
21
+ } ) ;
22
+ server . use (
23
+ rest . get ( "/hub/identities" , ( req , res , ctx ) => {
24
+ return res (
25
+ ctx . status ( 200 ) ,
26
+ ctx . json ( [
27
+ { id : 0 , name : "proxy-cred" , kind : "proxy" } ,
28
+ { id : 1 , name : "maven-cred" , kind : "maven" } ,
29
+ { id : 2 , name : "source-cred" , kind : "source" } ,
30
+ ] )
31
+ ) ;
32
+ } )
33
+ ) ;
34
+
45
35
it ( "Display switch statements on initial load" , async ( ) => {
46
36
render ( < Proxies /> ) ;
47
37
await screen . findByLabelText ( "HTTP proxy" ) ;
48
38
49
39
await screen . findByLabelText ( "HTTPS proxy" ) ;
50
40
} ) ;
51
41
52
- it . skip ( "Show HTTP proxy form when switch button clicked" , async ( ) => {
42
+ it ( "Show HTTP proxy form when switch button clicked" , async ( ) => {
53
43
render ( < Proxies /> ) ;
54
44
const httpProxySwitch = await screen . findByLabelText ( "HTTP proxy" ) ;
55
45
@@ -62,7 +52,7 @@ describe("Component: proxy-form", () => {
62
52
) ;
63
53
} ) ;
64
54
65
- it . skip ( "Show HTTPS proxy form when switch button clicked" , async ( ) => {
55
+ it ( "Show HTTPS proxy form when switch button clicked" , async ( ) => {
66
56
render ( < Proxies /> ) ;
67
57
const httpsProxySwitch = await screen . findByLabelText ( "HTTPS proxy" ) ;
68
58
@@ -75,14 +65,19 @@ describe("Component: proxy-form", () => {
75
65
) ;
76
66
} ) ;
77
67
78
- it . skip ( "Select http proxy identity" , async ( ) => {
79
- const identitiesData : Identity [ ] = [
80
- { id : 0 , name : "proxy-cred" , kind : "proxy" } ,
81
- { id : 1 , name : "maven-cred" , kind : "maven" } ,
82
- { id : 2 , name : "source-cred" , kind : "source" } ,
83
- ] ;
84
-
85
- mock . onGet ( `${ IDENTITIES } ` ) . reply ( 200 , identitiesData ) ;
68
+ it ( "Select http proxy identity" , async ( ) => {
69
+ server . use (
70
+ rest . get ( "/hub/identities" , ( req , res , ctx ) => {
71
+ return res (
72
+ ctx . status ( 200 ) ,
73
+ ctx . json ( [
74
+ { id : 0 , name : "proxy-cred" , kind : "proxy" } ,
75
+ { id : 1 , name : "maven-cred" , kind : "maven" } ,
76
+ { id : 2 , name : "source-cred" , kind : "source" } ,
77
+ ] )
78
+ ) ;
79
+ } )
80
+ ) ;
86
81
87
82
render ( < Proxies /> ) ;
88
83
const httpProxySwitch = await screen . findByLabelText ( "HTTP proxy" ) ;
@@ -112,14 +107,19 @@ describe("Component: proxy-form", () => {
112
107
expect ( sourceCred ) . toBeNull ( ) ; // it doesn't exist
113
108
} ) ;
114
109
115
- it . skip ( "Select https proxy identity" , async ( ) => {
116
- const identitiesData : Identity [ ] = [
117
- { id : 0 , name : "proxy-cred" , kind : "proxy" } ,
118
- { id : 1 , name : "maven-cred" , kind : "maven" } ,
119
- { id : 2 , name : "source-cred" , kind : "source" } ,
120
- ] ;
121
-
122
- mock . onGet ( `${ IDENTITIES } ` ) . reply ( 200 , identitiesData ) ;
110
+ it ( "Select https proxy identity" , async ( ) => {
111
+ server . use (
112
+ rest . get ( "/hub/identities" , ( req , res , ctx ) => {
113
+ return res (
114
+ ctx . status ( 200 ) ,
115
+ ctx . json ( [
116
+ { id : 0 , name : "proxy-cred" , kind : "proxy" } ,
117
+ { id : 1 , name : "maven-cred" , kind : "maven" } ,
118
+ { id : 2 , name : "source-cred" , kind : "source" } ,
119
+ ] )
120
+ ) ;
121
+ } )
122
+ ) ;
123
123
124
124
render ( < Proxies /> ) ;
125
125
const httpsProxySwitch = await screen . findByLabelText ( "HTTPS proxy" ) ;
0 commit comments