@@ -2,7 +2,6 @@ const auth = require('../lib/Auth');
22const Config = require ( '../lib/Config' ) ;
33const rest = require ( '../lib/rest' ) ;
44const request = require ( '../lib/request' ) ;
5- const { getSanitizedErrorCall } = require ( '../lib/TestUtils' ) ;
65const AudiencesRouter = require ( '../lib/Routers/AudiencesRouter' ) . AudiencesRouter ;
76
87describe ( 'AudiencesRouter' , ( ) => {
@@ -264,75 +263,75 @@ describe('AudiencesRouter', () => {
264263 } ) ;
265264
266265 it ( 'should only create with master key' , done => {
267- const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
268-
269- const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
266+ const logger = require ( '../lib/logger' ) . default ;
267+ const loggerErrorSpy = spyOn ( logger , 'error' ) . and . callThrough ( ) ;
268+ loggerErrorSpy . calls . reset ( ) ;
270269 Parse . _request ( 'POST' , 'push_audiences' , {
271270 name : 'My Audience' ,
272271 query : JSON . stringify ( { deviceType : 'ios' } ) ,
273272 } ) . then (
274273 ( ) => { } ,
275274 error => {
276275 expect ( error . message ) . toEqual ( 'Permission denied' ) ;
277- sanitizedErrorCall . checkMessage ( ' unauthorized: master key is required', callCountBefore ) ;
276+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( ' unauthorized: master key is required') ) ;
278277 done ( ) ;
279278 }
280279 ) ;
281280 } ) ;
282281
283282 it ( 'should only find with master key' , done => {
284- const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
285-
286- const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
283+ const logger = require ( '../lib/logger' ) . default ;
284+ const loggerErrorSpy = spyOn ( logger , 'error' ) . and . callThrough ( ) ;
285+ loggerErrorSpy . calls . reset ( ) ;
287286 Parse . _request ( 'GET' , 'push_audiences' , { } ) . then (
288287 ( ) => { } ,
289288 error => {
290289 expect ( error . message ) . toEqual ( 'Permission denied' ) ;
291- sanitizedErrorCall . checkMessage ( ' unauthorized: master key is required', callCountBefore ) ;
290+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( ' unauthorized: master key is required') ) ;
292291 done ( ) ;
293292 }
294293 ) ;
295294 } ) ;
296295
297296 it ( 'should only get with master key' , done => {
298- const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
299-
300- const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
297+ const logger = require ( '../lib/logger' ) . default ;
298+ const loggerErrorSpy = spyOn ( logger , 'error' ) . and . callThrough ( ) ;
299+ loggerErrorSpy . calls . reset ( ) ;
301300 Parse . _request ( 'GET' , `push_audiences/someId` , { } ) . then (
302301 ( ) => { } ,
303302 error => {
304303 expect ( error . message ) . toEqual ( 'Permission denied' ) ;
305- sanitizedErrorCall . checkMessage ( ' unauthorized: master key is required', callCountBefore ) ;
304+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( ' unauthorized: master key is required') ) ;
306305 done ( ) ;
307306 }
308307 ) ;
309308 } ) ;
310309
311310 it ( 'should only update with master key' , done => {
312- const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
313-
314- const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
311+ const logger = require ( '../lib/logger' ) . default ;
312+ const loggerErrorSpy = spyOn ( logger , 'error' ) . and . callThrough ( ) ;
313+ loggerErrorSpy . calls . reset ( ) ;
315314 Parse . _request ( 'PUT' , `push_audiences/someId` , {
316315 name : 'My Audience 2' ,
317316 } ) . then (
318317 ( ) => { } ,
319318 error => {
320319 expect ( error . message ) . toEqual ( 'Permission denied' ) ;
321- sanitizedErrorCall . checkMessage ( ' unauthorized: master key is required', callCountBefore ) ;
320+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( ' unauthorized: master key is required') ) ;
322321 done ( ) ;
323322 }
324323 ) ;
325324 } ) ;
326325
327326 it ( 'should only delete with master key' , done => {
328- const sanitizedErrorCall = getSanitizedErrorCall ( ) ;
329-
330- const callCountBefore = sanitizedErrorCall . callCountBefore ( ) ;
327+ const logger = require ( '../lib/logger' ) . default ;
328+ const loggerErrorSpy = spyOn ( logger , 'error' ) . and . callThrough ( ) ;
329+ loggerErrorSpy . calls . reset ( ) ;
331330 Parse . _request ( 'DELETE' , `push_audiences/someId` , { } ) . then (
332331 ( ) => { } ,
333332 error => {
334333 expect ( error . message ) . toEqual ( 'Permission denied' ) ;
335- sanitizedErrorCall . checkMessage ( ' unauthorized: master key is required', callCountBefore ) ;
334+ expect ( loggerErrorSpy ) . toHaveBeenCalledWith ( 'Sanitized error:' , jasmine . stringContaining ( ' unauthorized: master key is required') ) ;
336335 done ( ) ;
337336 }
338337 ) ;
0 commit comments