Skip to content

Commit eb1c4f0

Browse files
committed
refactor(test-preCompressed): async/await
1 parent 92e0f38 commit eb1c4f0

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

test/index.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,22 @@ describe('server', () => {
106106
.expect(200)));
107107

108108
describe('options.preCompressed', () => {
109-
it('Serve brotli (br) if supported', () => {
109+
beforeEach(() => { hexo.config.server.preCompressed = false; });
110+
111+
it('Serve brotli (br) if supported', async () => {
110112
hexo.config.server.preCompressed = true;
111113

112-
return Promise.using(
114+
await Promise.using(
113115
prepareServer(),
114116
app => request(app)
115117
.get('/foo%20bar.js')
116118
.set('Accept-Encoding', 'gzip, br')
117119
.expect('Content-Encoding', 'br')
118120
.expect('Content-Type', 'application/javascript; charset=utf-8')
119-
).finally(() => {
120-
hexo.config.server.preCompressed = false;
121-
});
121+
);
122122
});
123123

124-
it('Serve gzip if br is not supported', () => {
124+
it('Serve gzip if br is not supported', async () => {
125125
hexo.config.server.preCompressed = true;
126126

127127
return Promise.using(
@@ -131,15 +131,13 @@ describe('server', () => {
131131
.set('Accept-Encoding', 'gzip')
132132
.expect('Content-Encoding', 'gzip')
133133
.expect('Content-Type', 'application/javascript; charset=utf-8')
134-
).finally(() => {
135-
hexo.config.server.preCompressed = false;
136-
});
134+
);
137135
});
138136

139-
it('Disable', () => {
137+
it('Disable', async () => {
140138
hexo.config.server.preCompressed = false;
141139

142-
return Promise.using(
140+
await Promise.using(
143141
prepareServer(),
144142
app => request(app)
145143
.get('/foo%20bar.js')
@@ -150,32 +148,28 @@ describe('server', () => {
150148
);
151149
});
152150

153-
it('route / to /index.html (br)', () => {
151+
it('route / to /index.html (br)', async () => {
154152
hexo.config.server.preCompressed = true;
155153

156-
return Promise.using(
154+
await Promise.using(
157155
prepareServer(),
158156
app => request(app)
159157
.get('/foo/')
160158
.set('Accept-Encoding', 'gzip, br')
161159
.expect('Content-Encoding', 'br')
162-
).finally(() => {
163-
hexo.config.server.preCompressed = false;
164-
});
160+
);
165161
});
166162

167-
it('route / to /index.html (br)', () => {
163+
it('route / to /index.html (gzip)', async () => {
168164
hexo.config.server.preCompressed = true;
169165

170-
return Promise.using(
166+
await Promise.using(
171167
prepareServer(),
172168
app => request(app)
173169
.get('/foo/')
174170
.set('Accept-Encoding', 'gzip')
175171
.expect('Content-Encoding', 'gzip')
176-
).finally(() => {
177-
hexo.config.server.preCompressed = false;
178-
});
172+
);
179173
});
180174
});
181175

0 commit comments

Comments
 (0)