@@ -3039,7 +3039,6 @@ describe('REST server tests', () => {
3039
3039
endpoint : 'http://localhost/api' ,
3040
3040
modelNameMapping : {
3041
3041
user : 'myUser' ,
3042
- post : 'myPost' ,
3043
3042
} ,
3044
3043
} ) ;
3045
3044
handler = ( args ) =>
@@ -3053,7 +3052,7 @@ describe('REST server tests', () => {
3053
3052
method : 'post' ,
3054
3053
path : '/user' ,
3055
3054
query : { } ,
3056
- requestBody : { data : { type : 'user' , attributes : { name : 'User1' } } } ,
3055
+ requestBody : { data : { type : 'user' , attributes : { id : '1' , name : 'User1' } } } ,
3057
3056
prisma,
3058
3057
} )
3059
3058
) . resolves . toMatchObject ( {
@@ -3066,7 +3065,45 @@ describe('REST server tests', () => {
3066
3065
method : 'post' ,
3067
3066
path : '/myUser' ,
3068
3067
query : { } ,
3069
- requestBody : { data : { type : 'user' , attributes : { name : 'User1' } } } ,
3068
+ requestBody : { data : { type : 'user' , attributes : { id : '1' , name : 'User1' } } } ,
3069
+ prisma,
3070
+ } )
3071
+ ) . resolves . toMatchObject ( {
3072
+ status : 201 ,
3073
+ body : {
3074
+ links : { self : 'http://localhost/api/myUser/1' } ,
3075
+ } ,
3076
+ } ) ;
3077
+
3078
+ await expect (
3079
+ handler ( {
3080
+ method : 'get' ,
3081
+ path : '/myUser/1' ,
3082
+ query : { } ,
3083
+ prisma,
3084
+ } )
3085
+ ) . resolves . toMatchObject ( {
3086
+ status : 200 ,
3087
+ body : {
3088
+ links : { self : 'http://localhost/api/myUser/1' } ,
3089
+ } ,
3090
+ } ) ;
3091
+
3092
+ // works with unmapped model name
3093
+ await expect (
3094
+ handler ( {
3095
+ method : 'post' ,
3096
+ path : '/post' ,
3097
+ query : { } ,
3098
+ requestBody : {
3099
+ data : {
3100
+ type : 'post' ,
3101
+ attributes : { id : '1' , title : 'Post1' } ,
3102
+ relationships : {
3103
+ author : { data : { type : 'user' , id : '1' } } ,
3104
+ } ,
3105
+ } ,
3106
+ } ,
3070
3107
prisma,
3071
3108
} )
3072
3109
) . resolves . toMatchObject ( {
0 commit comments