@@ -122,11 +122,52 @@ describe('builder', () => {
122
122
123
123
Promise . resolve ( )
124
124
. then ( ( ) => api . user . getUsers ( ) )
125
- . then ( ( ) => api . user . deleteUser ( 1 ) )
125
+ . then ( ( ) => api . user . deleteUser ( '1' ) )
126
126
. then ( ( ) => api . user . getUsers ( ) )
127
127
. then ( expectUserToBeRemoved ) ;
128
128
} ) ;
129
129
130
+ describe ( 'after deletion' , ( ) => {
131
+ it ( 'calls the apiFn again when marked as byId === true' , ( ) => {
132
+ const myConfig = config ( ) ;
133
+ const spy = sinon . spy ( ) ;
134
+
135
+ const getUserById = ( ) => {
136
+ spy ( ) ;
137
+ return Promise . resolve ( { id : 4 } ) ;
138
+ } ;
139
+ getUserById . operation = 'READ' ;
140
+ getUserById . byId = true ;
141
+
142
+ myConfig . user . api . getUserById = getUserById ;
143
+
144
+ const api = build ( myConfig ) ;
145
+
146
+ return Promise . resolve ( )
147
+ . then ( ( ) => api . user . getUserById ( '1' ) )
148
+ . then ( ( ) => api . user . deleteUser ( '1' ) )
149
+ . then ( ( ) => api . user . getUserById ( '1' ) )
150
+ . then ( ( ) => {
151
+ expect ( spy ) . to . have . been . calledTwice ;
152
+ } ) ;
153
+ } ) ;
154
+
155
+ it ( 'returns null for normal read operation when entity is requested again' , ( ) => {
156
+ const myConfig = config ( ) ;
157
+
158
+ const api = build ( myConfig ) ;
159
+
160
+ return Promise . resolve ( )
161
+ . then ( ( ) => api . user . getUser ( '1' ) )
162
+ . then ( ( ) => api . user . deleteUser ( '1' ) )
163
+ . then ( ( ) => api . user . getUser ( '1' ) )
164
+ . then ( ( user ) => {
165
+ expect ( user ) . to . be . null ;
166
+ } ) ;
167
+ } ) ;
168
+ } ) ;
169
+
170
+
130
171
it ( 'TTL set to zero means we never get a cache hit' , ( done ) => {
131
172
const myConfig = config ( ) ;
132
173
myConfig . user . ttl = 0 ;
0 commit comments