File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ const app = require ( "../app" ) ;
2
+ const request = require ( "supertest" ) ;
3
+
4
+ describe ( "Pet Service" , ( ) => {
5
+ describe ( "Normal scenario" , ( ) => {
6
+ it ( "should save the pet in the database" , async ( ) => {
7
+ const response = await request ( app ) . post ( "/api/pet" ) . send ( {
8
+ id : 5 ,
9
+ name : "Sandy" ,
10
+ type : "Hamster"
11
+ } ) ;
12
+
13
+ expect ( response . headers [ "content-type" ] ) . toEqual ( expect . stringContaining ( "application/json" ) ) ;
14
+ } ) ;
15
+
16
+ it ( "should response with 201 when new pet created with all the fields" , async ( ) => {
17
+ const response = await request ( app ) . post ( "/api/pet" ) . send ( {
18
+ id : 5 ,
19
+ name : "Sandy" ,
20
+ type : "Hamster"
21
+ } ) ;
22
+
23
+ expect ( response . statusCode ) . toBe ( 201 ) ;
24
+ } ) ;
25
+
26
+ it ( "should be content type of json in the header when a new pet is added" , async ( ) => {
27
+ const response = await request ( app ) . post ( "/api/pet" ) . send ( {
28
+ id : 5 ,
29
+ name : "Sandy" ,
30
+ type : "Hamster"
31
+ } ) ;
32
+
33
+ expect ( response . headers [ "content-type" ] ) . toEqual ( expect . stringContaining ( "application/json" ) ) ;
34
+ } ) ;
35
+ } ) ;
36
+ } ) ;
You can’t perform that action at this time.
0 commit comments