@@ -89,7 +89,7 @@ describe('Project Entities', () => {
89
89
name : 'someone 1'
90
90
} ,
91
91
tags : [ ]
92
- }
92
+ } ;
93
93
let apiClient : AxiosInstance ;
94
94
async function callMockCreate ( entity : any ) : Promise < dataHelpers . WrappedEntity > {
95
95
apiClient = api . getApiClient ( 'http://baseurl' , 'somekey' ) ;
@@ -102,7 +102,7 @@ describe('Project Entities', () => {
102
102
}
103
103
it ( 'should call POST /projects/:pid/entities endpoint with entity' , async ( ) => {
104
104
const entity = userEntity ;
105
- const expectedEntity = dataHelpers . expandEntity ( entity )
105
+ const expectedEntity = dataHelpers . expandEntity ( entity ) ;
106
106
await callMockCreate ( entity ) ;
107
107
expect ( apiClient . post ) . toHaveBeenCalledWith ( '/projects/project1/entities' , expectedEntity ) ;
108
108
} ) ;
@@ -113,32 +113,58 @@ describe('Project Entities', () => {
113
113
expect ( entity ) . toMatchSnapshot ( ) ;
114
114
} ) ;
115
115
} ) ;
116
- describe ( 'put ' , ( ) => {
116
+ describe ( 'patch ' , ( ) => {
117
117
const userEntity = {
118
118
data : {
119
119
name : 'someone 1'
120
120
} ,
121
121
tags : [ ]
122
- }
123
- let apiClient : AxiosInstance ;
124
- async function callMockPut ( entity : any ) : Promise < dataHelpers . WrappedEntity > {
122
+ } ;
123
+ async function callMockUpdate ( entity : any ) : Promise < dataHelpers . WrappedEntity > {
125
124
apiClient = api . getApiClient ( 'http://baseurl' , 'somekey' ) ;
126
- jest . spyOn ( apiClient , 'put ' ) . mockReturnValue ( Promise . resolve ( { data :
125
+ jest . spyOn ( apiClient , 'patch ' ) . mockReturnValue ( Promise . resolve ( { data :
127
126
{ entity } } ) ) ;
128
127
jest . spyOn ( dataHelpers , 'wrapEntity' ) ;
129
128
const project = getProjectApi ( 'project1' , apiClient ) ;
130
- const ent = await project . entities . put ( entity ) ;
129
+ const ent = await project . entities . update ( entity ) ;
131
130
return ent ;
132
131
}
133
- it ( 'should call PUT /projects/:pid/entities/:eid endpoint with entity' , async ( ) => {
132
+ it ( 'should call PATCH /projects/:pid/entities/:eid endpoint with entity' , async ( ) => {
134
133
const entity = { ...userEntity } ;
135
- entity [ '_id' ] = 'entity1' ;
136
- const expectedEntity = dataHelpers . expandEntity ( entity ) ;
137
- const frozen = Object . freeze ( entity ) ;
138
- await callMockPut ( frozen ) ;
139
- expect ( apiClient . put ) . toHaveBeenCalledWith (
140
- '/projects/project1/entities/entity1' , expectedEntity ) ;
134
+ entity [ '_id' ] = 'entity1' ;
135
+ const expectedEntity = dataHelpers . expandEntity ( entity ) ;
136
+ const frozen = Object . freeze ( entity ) ;
137
+ await callMockUpdate ( frozen ) ;
138
+ expect ( apiClient . patch ) . toHaveBeenCalledWith (
139
+ '/projects/project1/entities/entity1' , expectedEntity ) ;
141
140
} ) ;
142
141
} ) ;
142
+ describe ( 'put' , ( ) => {
143
+ const userEntity = {
144
+ data : {
145
+ name : 'someone 1'
146
+ } ,
147
+ tags : [ ]
148
+ } ;
149
+ let apiClient : AxiosInstance ;
150
+ async function callMockPut ( entity : any ) : Promise < dataHelpers . WrappedEntity > {
151
+ apiClient = api . getApiClient ( 'http://baseurl' , 'somekey' ) ;
152
+ jest . spyOn ( apiClient , 'put' ) . mockReturnValue ( Promise . resolve ( { data :
153
+ { entity } } ) ) ;
154
+ jest . spyOn ( dataHelpers , 'wrapEntity' ) ;
155
+ const project = getProjectApi ( 'project1' , apiClient ) ;
156
+ const ent = await project . entities . put ( entity ) ;
157
+ return ent ;
158
+ }
159
+ it ( 'should call PUT /projects/:pid/entities/:eid endpoint with entity' , async ( ) => {
160
+ const entity = { ...userEntity } ;
161
+ entity [ '_id' ] = 'entity1' ;
162
+ const expectedEntity = dataHelpers . expandEntity ( entity ) ;
163
+ const frozen = Object . freeze ( entity ) ;
164
+ await callMockPut ( frozen ) ;
165
+ expect ( apiClient . put ) . toHaveBeenCalledWith (
166
+ '/projects/project1/entities/entity1' , expectedEntity ) ;
167
+ } ) ;
168
+ } ) ;
143
169
} ) ;
144
170
} ) ;
0 commit comments