@@ -5,25 +5,41 @@ import {
5
5
import {
6
6
clear as clearHttp ,
7
7
testRouter ,
8
- testUpload ,
9
8
} from '@lykmapipo/express-test-helpers' ;
10
9
import fileRouter from '../src/file.http.router' ;
11
10
11
+ const properties = [
12
+ 'length' ,
13
+ 'chunkSize' ,
14
+ 'uploadDate' ,
15
+ 'md5' ,
16
+ 'filename' ,
17
+ 'contentType' ,
18
+ 'aliases' ,
19
+ 'metadata' ,
20
+ '_id' ,
21
+ '__v' ,
22
+ ] ;
23
+
24
+ const options = {
25
+ pathSingle : '/files/:bucket/:id' ,
26
+ pathList : '/files/:bucket' ,
27
+ pathSchema : '/files/:bucket/schema' ,
28
+ } ;
29
+
12
30
describe . only ( 'HTTP API' , ( ) => {
13
31
before ( ( ) => clearHttp ( ) ) ;
14
32
before ( done => clearDatabase ( done ) ) ;
15
33
16
- const options = {
17
- pathSingle : '/files/:bucket/:id' ,
18
- pathList : '/files/:bucket' ,
19
- pathSchema : '/files/:bucket/schema' ,
20
- } ;
21
-
22
- expect ( testUpload ) . to . exist ;
23
-
24
34
it ( 'should handle HTTP GET on /files/:bucket/schema' , done => {
25
35
const { testGetSchema } = testRouter ( options , fileRouter ) ;
26
- testGetSchema ( { bucket : 'files' } ) . expect ( 200 , done ) ;
36
+ testGetSchema ( { bucket : 'files' } ) . expect ( 200 , ( error , { body } ) => {
37
+ expect ( error ) . to . not . exist ;
38
+ expect ( body ) . to . exist ;
39
+ expect ( body ) . to . have . all . keys ( 'title' , 'type' , 'properties' ) ;
40
+ expect ( body . properties ) . to . have . all . keys ( ...properties ) ;
41
+ done ( error , body ) ;
42
+ } ) ;
27
43
} ) ;
28
44
29
45
after ( ( ) => clearHttp ( ) ) ;
0 commit comments