-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename tests to match their implementation directory structure
- Loading branch information
1 parent
ff6191b
commit 92ce6fb
Showing
10 changed files
with
172 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
lib/__tests__/conditional-get.js → lib/middleware/__tests__/conditional-get.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 1 addition & 27 deletions
28
lib/__tests__/headers.js → lib/middleware/__tests__/headers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const koala = require('../..'); | ||
const request = require('supertest'); | ||
const PassThrough = require('stream').PassThrough; | ||
|
||
describe('Middlewares', () => { | ||
describe('Response Time', () => { | ||
test('should get X-Response-Time correctly by default', () => { | ||
const app = koala(); | ||
|
||
return request(app.callback()) | ||
.get('/') | ||
.expect(404) | ||
.expect('X-Response-Time', /s$/); | ||
}); | ||
test( | ||
'should not get X-Response-Time by options.responseTime = false', | ||
() => { | ||
const app = koala({ | ||
responseTime: false | ||
}); | ||
|
||
return request(app.callback()) | ||
.get('/') | ||
.expect(404) | ||
.expect(res => { | ||
expect(res.headers['X-Response-Time']).toBe(undefined); | ||
}); | ||
} | ||
); | ||
}); | ||
|
||
describe('Object Streams', () => { | ||
test('should be supported', () => { | ||
const app = koala(); | ||
app.use(function * (next) { | ||
const body = this.body = new PassThrough({ | ||
objectMode: true | ||
}); | ||
|
||
body.write({ | ||
message: 'a' | ||
}); | ||
|
||
body.write({ | ||
message: 'b' | ||
}); | ||
|
||
body.end(); | ||
}); | ||
|
||
return request(app.callback()) | ||
.get('/') | ||
.expect(200) | ||
.expect([{ | ||
message: 'a' | ||
}, { | ||
message: 'b' | ||
}]); | ||
}); | ||
}); | ||
|
||
describe('Session', () => { | ||
test('should has this.session by default', () => { | ||
const app = koala(); | ||
|
||
app.use(function * () { | ||
this.body = this.session; | ||
}); | ||
|
||
return request(app.callback()) | ||
.get('/') | ||
.expect('{}'); | ||
}); | ||
test('should has no this.session by options.session = false', () => { | ||
const app = koala({ | ||
session: false | ||
}); | ||
|
||
app.use(function * () { | ||
this.body = this.session === undefined; | ||
}); | ||
|
||
return request(app.callback()) | ||
.get('/') | ||
.expect('true'); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.