Skip to content

Commit ad376d0

Browse files
committed
fix: migrate static-PublicPath tests
1 parent 793620b commit ad376d0

File tree

1 file changed

+88
-48
lines changed

1 file changed

+88
-48
lines changed

test/server/static-publicPath-option.test.js

Lines changed: 88 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ describe('static.publicPath option', () => {
4242
});
4343
});
4444

45-
it('Request to index', (done) => {
46-
req.get(`${staticPublicPath}/`).expect(200, /Heyo/, done);
45+
it('Request to index', async () => {
46+
const { status, text } = await req.get(`${staticPublicPath}/`);
47+
expect(status).toEqual(200);
48+
expect(text).toContain('Heyo');
4749
});
4850

49-
it('Request to other file', (done) => {
50-
req.get(`${staticPublicPath}/other.html`).expect(200, /Other html/, done);
51+
it('Request to other file', async () => {
52+
const { status, text } = await req.get(`${staticPublicPath}/other.html`);
53+
expect(status).toEqual(200);
54+
expect(text).toContain('Other html');
5155
});
5256
});
5357

@@ -75,12 +79,15 @@ describe('static.publicPath option', () => {
7579
});
7680
});
7781

78-
it("shouldn't list the files inside the assets folder (404)", (done) => {
79-
req.get(`${staticPublicPath}/assets/`).expect(404, done);
82+
it("shouldn't list the files inside the assets folder (404)", async () => {
83+
const { status } = await req.get(`${staticPublicPath}/assets/`);
84+
expect(status).toEqual(404);
8085
});
8186

82-
it('should show Heyo. because bar has index.html inside it (200)', (done) => {
83-
req.get(`${staticPublicPath}/bar/`).expect(200, /Heyo/, done);
87+
it('should show Heyo. because bar has index.html inside it (200)', async () => {
88+
const { status, text } = await req.get(`${staticPublicPath}/bar/`);
89+
expect(status).toEqual(200);
90+
expect(text).toContain('Heyo');
8491
});
8592
});
8693

@@ -108,12 +115,15 @@ describe('static.publicPath option', () => {
108115
});
109116
});
110117

111-
it('should list the files inside the assets folder (200)', (done) => {
112-
req.get(`${staticPublicPath}/assets/`).expect(200, done);
118+
it('should list the files inside the assets folder (200)', async () => {
119+
const { status } = await req.get(`${staticPublicPath}/assets/`);
120+
expect(status).toEqual(200);
113121
});
114122

115-
it('should show Heyo. because bar has index.html inside it (200)', (done) => {
116-
req.get(`${staticPublicPath}/bar/`).expect(200, /Heyo/, done);
123+
it('should show Heyo. because bar has index.html inside it (200)', async () => {
124+
const { status, text } = await req.get(`${staticPublicPath}/bar/`);
125+
expect(status).toEqual(200);
126+
expect(text).toContain('Heyo');
117127
});
118128
});
119129

@@ -140,12 +150,15 @@ describe('static.publicPath option', () => {
140150
});
141151
});
142152

143-
it('should list the files inside the assets folder (200)', (done) => {
144-
req.get(`${staticPublicPath}/assets/`).expect(200, done);
153+
it('should list the files inside the assets folder (200)', async () => {
154+
const { status } = await req.get(`${staticPublicPath}/assets/`);
155+
expect(status).toEqual(200);
145156
});
146157

147-
it('should show Heyo. because bar has index.html inside it (200)', (done) => {
148-
req.get(`${staticPublicPath}/bar/`).expect(200, /Heyo/, done);
158+
it('should show Heyo. because bar has index.html inside it (200)', async () => {
159+
const { status, text } = await req.get(`${staticPublicPath}/bar/`);
160+
expect(status).toEqual(200);
161+
expect(text).toContain('Heyo');
149162
});
150163
});
151164

@@ -177,12 +190,16 @@ describe('static.publicPath option', () => {
177190
});
178191
});
179192

180-
it('Request to first directory', (done) => {
181-
req.get(`${staticPublicPath}/`).expect(200, /Heyo/, done);
193+
it('Request to first directory', async () => {
194+
const { status, text } = await req.get(`${staticPublicPath}/`);
195+
expect(status).toEqual(200);
196+
expect(text).toContain('Heyo');
182197
});
183198

184-
it('Request to second directory', (done) => {
185-
req.get(`${staticPublicPath}/foo.html`).expect(200, /Foo!/, done);
199+
it('Request to second directory', async () => {
200+
const { status, text } = await req.get(`${staticPublicPath}/foo.html`);
201+
expect(status).toEqual(200);
202+
expect(text).toContain('Foo!');
186203
});
187204
});
188205

@@ -209,8 +226,9 @@ describe('static.publicPath option', () => {
209226
});
210227
});
211228

212-
it('Request to page', (done) => {
213-
req.get(`${staticPublicPath}/index.html`).expect(200, done);
229+
it('Request to page', async () => {
230+
const { status } = await req.get(`${staticPublicPath}/index.html`);
231+
expect(status).toEqual(200);
214232
});
215233
});
216234

@@ -264,28 +282,34 @@ describe('static.publicPath option', () => {
264282
testServer.close(done);
265283
});
266284

267-
it('GET request', (done) => {
268-
req.get(`${staticPublicPath}/`).expect(200, done);
285+
it('GET request', async () => {
286+
const { status } = await req.get(`${staticPublicPath}/`);
287+
expect(status).toEqual(200);
269288
});
270289

271-
it('HEAD request', (done) => {
272-
req.head(`${staticPublicPath}/`).expect(200, done);
290+
it('HEAD request', async () => {
291+
const { status } = await req.head(`${staticPublicPath}/`);
292+
expect(status).toEqual(200);
273293
});
274294

275-
it('POST request', (done) => {
276-
req.post(`${staticPublicPath}/`).expect(404, done);
295+
it('POST request', async () => {
296+
const { status } = await req.post(`${staticPublicPath}/`);
297+
expect(status).toEqual(404);
277298
});
278299

279-
it('PUT request', (done) => {
280-
req.put(`${staticPublicPath}/`).expect(404, done);
300+
it('PUT request', async () => {
301+
const { status } = await req.put(`${staticPublicPath}/`);
302+
expect(status).toEqual(404);
281303
});
282304

283-
it('DELETE request', (done) => {
284-
req.delete(`${staticPublicPath}/`).expect(404, done);
305+
it('DELETE request', async () => {
306+
const { status } = await req.delete(`${staticPublicPath}/`);
307+
expect(status).toEqual(404);
285308
});
286309

287-
it('PATCH request', (done) => {
288-
req.patch(`${staticPublicPath}/`).expect(404, done);
310+
it('PATCH request', async () => {
311+
const { status } = await req.patch(`${staticPublicPath}/`);
312+
expect(status).toEqual(404);
289313
});
290314
});
291315

@@ -319,16 +343,24 @@ describe('static.publicPath option', () => {
319343
});
320344
});
321345

322-
it('Request the first path to index', (done) => {
323-
req.get(`${staticPublicPath}/`).expect(200, /Heyo/, done);
346+
it('Request the first path to index', async () => {
347+
const { status, text } = await req.get(`${staticPublicPath}/`);
348+
expect(status).toEqual(200);
349+
expect(text).toContain('Heyo');
324350
});
325351

326-
it('Request the first path to other file', (done) => {
327-
req.get(`${staticPublicPath}/other.html`).expect(200, /Other html/, done);
352+
it('Request the first path to other file', async () => {
353+
const { status, text } = await req.get(`${staticPublicPath}/other.html`);
354+
expect(status).toEqual(200);
355+
expect(text).toContain('Other html');
328356
});
329357

330-
it('Request the second path to foo', (done) => {
331-
req.get(`${otherStaticPublicPath}/foo.html`).expect(200, /Foo!/, done);
358+
it('Request the second path to foo', async () => {
359+
const { status, text } = await req.get(
360+
`${otherStaticPublicPath}/foo.html`
361+
);
362+
expect(status).toEqual(200);
363+
expect(text).toContain('Foo!');
332364
});
333365
});
334366

@@ -362,20 +394,28 @@ describe('static.publicPath option', () => {
362394
});
363395
});
364396

365-
it('Request the first path to index', (done) => {
366-
req.get(`${staticPublicPath}/`).expect(200, /Heyo/, done);
397+
it('Request the first path to index', async () => {
398+
const { status, text } = await req.get(`${staticPublicPath}/`);
399+
expect(status).toEqual(200);
400+
expect(text).toContain('Heyo');
367401
});
368402

369-
it('Request the first path to other file', (done) => {
370-
req.get(`${staticPublicPath}/other.html`).expect(200, /Other html/, done);
403+
it('Request the first path to other file', async () => {
404+
const { status, text } = await req.get(`${staticPublicPath}/other.html`);
405+
expect(status).toEqual(200);
406+
expect(text).toContain('Other html');
371407
});
372408

373-
it('Request the first path to foo', (done) => {
374-
req.get(`${staticPublicPath}/foo.html`).expect(200, /Foo!/, done);
409+
it('Request the first path to foo', async () => {
410+
const { status, text } = await req.get(`${staticPublicPath}/foo.html`);
411+
expect(status).toEqual(200);
412+
expect(text).toContain('Foo!');
375413
});
376414

377-
it('Request the second path to foo', (done) => {
378-
req.get(`${otherStaticPublicPath}/foo.html`).expect(200, /Foo!/, done);
415+
it('Request the second path to foo', async () => {
416+
const { status, text } = await req.get(`${staticPublicPath}/foo.html`);
417+
expect(status).toEqual(200);
418+
expect(text).toContain('Foo!');
379419
});
380420
});
381421
});

0 commit comments

Comments
 (0)