@@ -172,103 +172,97 @@ export function iit(name, fn) {
172172// gives us bad error messages in tests.
173173// The only way to do this in Jasmine is to monkey patch a method
174174// to the object :-(
175- Map . prototype [ 'jasmineToString' ] =
176- function ( ) {
177- var m = this ;
178- if ( ! m ) {
179- return '' + m ;
180- }
181- var res = [ ] ;
182- m . forEach ( ( v , k ) => { res . push ( `${ k } :${ v } ` ) ; } ) ;
183- return `{ ${ res . join ( ',' ) } }` ;
184- }
185-
186- _global . beforeEach ( function ( ) {
187- jasmine . addMatchers ( {
188- // Custom handler for Map as Jasmine does not support it yet
189- toEqual : function ( util , customEqualityTesters ) {
190- return {
191- compare : function ( actual , expected ) {
192- return { pass : util . equals ( actual , expected , [ compareMap ] ) } ;
193- }
194- } ;
175+ Map . prototype [ 'jasmineToString' ] = function ( ) {
176+ var m = this ;
177+ if ( ! m ) {
178+ return '' + m ;
179+ }
180+ var res = [ ] ;
181+ m . forEach ( ( v , k ) => { res . push ( `${ k } :${ v } ` ) ; } ) ;
182+ return `{ ${ res . join ( ',' ) } }` ;
183+ } ;
184+
185+ _global . beforeEach ( function ( ) {
186+ jasmine . addMatchers ( {
187+ // Custom handler for Map as Jasmine does not support it yet
188+ toEqual : function ( util , customEqualityTesters ) {
189+ return {
190+ compare : function ( actual , expected ) {
191+ return { pass : util . equals ( actual , expected , [ compareMap ] ) } ;
192+ }
193+ } ;
195194
196- function compareMap ( actual , expected ) {
197- if ( actual instanceof Map ) {
198- var pass = actual . size === expected . size ;
199- if ( pass ) {
200- actual . forEach ( ( v , k ) => { pass = pass && util . equals ( v , expected . get ( k ) ) ; } ) ;
201- }
202- return pass ;
203- } else {
204- return undefined ;
205- }
195+ function compareMap ( actual , expected ) {
196+ if ( actual instanceof Map ) {
197+ var pass = actual . size === expected . size ;
198+ if ( pass ) {
199+ actual . forEach ( ( v , k ) => { pass = pass && util . equals ( v , expected . get ( k ) ) ; } ) ;
206200 }
207- } ,
201+ return pass ;
202+ } else {
203+ return undefined ;
204+ }
205+ }
206+ } ,
208207
209- toBePromise : function ( ) {
210- return {
211- compare : function ( actual , expectedClass ) {
212- var pass = typeof actual === 'object' && typeof actual . then === 'function' ;
213- return {
214- pass : pass ,
215- get message ( ) { return 'Expected ' + actual + ' to be a promise' ; }
216- } ;
217- }
218- } ;
219- } ,
208+ toBePromise : function ( ) {
209+ return {
210+ compare : function ( actual , expectedClass ) {
211+ var pass = typeof actual === 'object' && typeof actual . then === 'function' ;
212+ return { pass : pass , get message ( ) { return 'Expected ' + actual + ' to be a promise' ; } } ;
213+ }
214+ } ;
215+ } ,
220216
221- toBeAnInstanceOf : function ( ) {
217+ toBeAnInstanceOf : function ( ) {
218+ return {
219+ compare : function ( actual , expectedClass ) {
220+ var pass = typeof actual === 'object' && actual instanceof expectedClass ;
222221 return {
223- compare : function ( actual , expectedClass ) {
224- var pass = typeof actual === 'object' && actual instanceof expectedClass ;
225- return {
226- pass : pass ,
227- get message ( ) {
228- return 'Expected ' + actual + ' to be an instance of ' + expectedClass ;
229- }
230- } ;
222+ pass : pass ,
223+ get message ( ) {
224+ return 'Expected ' + actual + ' to be an instance of ' + expectedClass ;
231225 }
232226 } ;
233- } ,
227+ }
228+ } ;
229+ } ,
234230
235- toHaveText : function ( ) {
231+ toHaveText : function ( ) {
232+ return {
233+ compare : function ( actual , expectedText ) {
234+ var actualText = elementText ( actual ) ;
236235 return {
237- compare : function ( actual , expectedText ) {
238- var actualText = elementText ( actual ) ;
239- return {
240- pass : actualText == expectedText ,
241- get message ( ) {
242- return 'Expected ' + actualText + ' to be equal to ' + expectedText ;
243- }
244- } ;
245- }
236+ pass : actualText == expectedText ,
237+ get message ( ) { return 'Expected ' + actualText + ' to be equal to ' + expectedText ; }
246238 } ;
247- } ,
239+ }
240+ } ;
241+ } ,
242+
243+ toImplement : function ( ) {
244+ return {
245+ compare : function ( actualObject , expectedInterface ) {
246+ var objProps = Object . keys ( actualObject . constructor . prototype ) ;
247+ var intProps = Object . keys ( expectedInterface . prototype ) ;
248+
249+ var missedMethods = [ ] ;
250+ intProps . forEach ( ( k ) => {
251+ if ( ! actualObject . constructor . prototype [ k ] ) missedMethods . push ( k ) ;
252+ } ) ;
248253
249- toImplement : function ( ) {
250254 return {
251- compare : function ( actualObject , expectedInterface ) {
252- var objProps = Object . keys ( actualObject . constructor . prototype ) ;
253- var intProps = Object . keys ( expectedInterface . prototype ) ;
254-
255- var missedMethods = [ ] ;
256- intProps . forEach ( ( k ) => {
257- if ( ! actualObject . constructor . prototype [ k ] ) missedMethods . push ( k ) ;
258- } ) ;
259-
260- return {
261- pass : missedMethods . length == 0 ,
262- get message ( ) {
263- return 'Expected ' + actualObject + ' to have the following methods: ' +
264- missedMethods . join ( ", " ) ;
265- }
266- } ;
255+ pass : missedMethods . length == 0 ,
256+ get message ( ) {
257+ return 'Expected ' + actualObject + ' to have the following methods: ' +
258+ missedMethods . join ( ", " ) ;
267259 }
268260 } ;
269261 }
270- } ) ;
271- } ) ;
262+ } ;
263+ }
264+ } ) ;
265+ } ) ;
272266
273267export interface GuinessCompatibleSpy extends jasmine . Spy {
274268 /** By chaining the spy with and.returnValue, all calls to the function will return a specific
0 commit comments