55 * Released under the MIT license.
66 */
77
8- import { promisify } from 'util' ;
98import request from 'supertest' ;
109import koa from 'koa' ;
1110import betterBody from '../src' ;
@@ -16,11 +15,12 @@ test('should accept opts.extendTypes.custom `foo/bar-x` as text', async () => {
1615 extendTypes : {
1716 custom : [ 'foo/bar-x' ] ,
1817 } ,
18+
1919 handler : function * handler ( ctx , opts ) {
20- test . strictEqual ( typeof ctx , 'object' ) ;
21- test . strictEqual ( typeof this , 'object' ) ;
22- test . strictEqual ( typeof ctx . request . text , 'function' ) ;
23- test . strictEqual ( typeof this . request . text , 'function' ) ;
20+ expect ( typeof ctx ) . toStrictEqual ( 'object' ) ;
21+ expect ( typeof this ) . toStrictEqual ( 'object' ) ;
22+ expect ( typeof ctx . request . text ) . toStrictEqual ( 'function' ) ;
23+ expect ( typeof this . request . text ) . toStrictEqual ( 'function' ) ;
2424
2525 this . request . body = yield this . request . text ( opts ) ;
2626 } ,
@@ -29,22 +29,19 @@ test('should accept opts.extendTypes.custom `foo/bar-x` as text', async () => {
2929
3030 app = app
3131 . use ( function * abc ( next ) {
32- test . strictEqual ( typeof this . request . body , 'string' ) ;
33- test . strictEqual ( this . request . body , 'message=lol' ) ;
32+ expect ( this . request . body ) . toStrictEqual ( 'message=lol' ) ;
3433 this . body = this . request . body ;
3534 yield * next ;
3635 } )
3736 // eslint-disable-next-line require-yield
3837 . use ( function * abc ( ) {
39- test . strictEqual ( this . body , 'message=lol' ) ;
38+ expect ( this . body ) . toStrictEqual ( 'message=lol' ) ;
4039 } ) ;
4140
42- await promisify (
43- request ( app . callback ( ) )
44- . post ( '/' )
45- . type ( 'foo/bar-x' )
46- . send ( 'message=lol' )
47- . expect ( 200 )
48- . expect ( 'message=lol' ) . end ,
49- ) ( ) ;
41+ await request ( app . callback ( ) )
42+ . post ( '/' )
43+ . type ( 'foo/bar-x' )
44+ . send ( 'message=lol' )
45+ . expect ( 200 )
46+ . expect ( 'message=lol' ) ;
5047} ) ;
0 commit comments