Skip to content

Commit 4f06dbc

Browse files
committed
axios.spec.ts: add tests for baseUrls with trailing slashes
1 parent ecc2bd4 commit 4f06dbc

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

tests/axios.spec.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,40 @@ describe('When using baseUrl with axios', () => {
3333
})
3434

3535
const baseUrlParams = [
36+
{
37+
baseUrl: undefined,
38+
api: {
39+
entities: {
40+
href: '/entities'
41+
},
42+
_links: {
43+
self: {
44+
href: 'http://localhost:3000/'
45+
}
46+
}
47+
},
48+
expectedFetches: [
49+
'/',
50+
'/entities'
51+
]
52+
},
53+
{
54+
baseUrl: '/',
55+
api: {
56+
entities: {
57+
href: '/entities'
58+
},
59+
_links: {
60+
self: {
61+
href: 'http://localhost:3000/'
62+
}
63+
}
64+
},
65+
expectedFetches: [
66+
'/',
67+
'/entities'
68+
]
69+
},
3670
{
3771
baseUrl: 'http://localhost:3000',
3872
api: {
@@ -50,6 +84,23 @@ describe('When using baseUrl with axios', () => {
5084
'http://localhost:3000/entities'
5185
]
5286
},
87+
{
88+
baseUrl: 'http://localhost:3000/',
89+
api: {
90+
entities: {
91+
href: '/entities'
92+
},
93+
_links: {
94+
self: {
95+
href: 'http://localhost:3000/'
96+
}
97+
}
98+
},
99+
expectedFetches: [
100+
'http://localhost:3000/',
101+
'http://localhost:3000/entities'
102+
]
103+
},
53104
{
54105
baseUrl: 'http://localhost:3000/api',
55106
api: {
@@ -67,6 +118,23 @@ describe('When using baseUrl with axios', () => {
67118
'http://localhost:3000/api/entities'
68119
]
69120
},
121+
{
122+
baseUrl: 'http://localhost:3000/api/',
123+
api: {
124+
entities: {
125+
href: '/api/entities'
126+
},
127+
_links: {
128+
self: {
129+
href: 'http://localhost:3000/api'
130+
}
131+
}
132+
},
133+
expectedFetches: [
134+
'http://localhost:3000/api/',
135+
'http://localhost:3000/api/entities'
136+
]
137+
},
70138
{
71139
baseUrl: '/api',
72140
api: {
@@ -83,6 +151,23 @@ describe('When using baseUrl with axios', () => {
83151
'/api/',
84152
'/api/entities'
85153
]
154+
},
155+
{
156+
baseUrl: '/api/',
157+
api: {
158+
entities: {
159+
href: '/api/entities'
160+
},
161+
_links: {
162+
self: {
163+
href: '/api'
164+
}
165+
}
166+
},
167+
expectedFetches: [
168+
'/api/',
169+
'/api/entities'
170+
]
86171
}
87172
]
88173
baseUrlParams.forEach(({ baseUrl, api, expectedFetches }) => {

0 commit comments

Comments
 (0)