| 
									
										
										
										
											2021-07-05 21:31:51 +02:00
										 |  |  | var describe; | 
					
						
							|  |  |  | var test; | 
					
						
							|  |  |  | var expect; | 
					
						
							| 
									
										
										
										
											2020-04-13 10:31:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | // Stores the results of each test and suite. Has a terrible
 | 
					
						
							|  |  |  | // name to avoid name collision.
 | 
					
						
							| 
									
										
										
										
											2021-07-05 21:31:51 +02:00
										 |  |  | var __TestResults__ = {}; | 
					
						
							| 
									
										
										
										
											2020-04-19 23:01:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-04 20:23:46 -07:00
										 |  |  | // So test names like "toString" don't automatically produce an error
 | 
					
						
							|  |  |  | Object.setPrototypeOf(__TestResults__, null); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | // This array is used to communicate with the C++ program. It treats
 | 
					
						
							|  |  |  | // each message in this array as a separate message. Has a terrible
 | 
					
						
							|  |  |  | // name to avoid name collision.
 | 
					
						
							| 
									
										
										
										
											2021-07-05 21:31:51 +02:00
										 |  |  | var __UserOutput__ = []; | 
					
						
							| 
									
										
										
										
											2020-05-26 20:31:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | // We also rebind console.log here to use the array above
 | 
					
						
							|  |  |  | console.log = (...args) => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     __UserOutput__.push(args.join(" ")); | 
					
						
							| 
									
										
										
										
											2020-04-21 19:21:26 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | class ExpectationError extends Error { | 
					
						
							| 
									
										
										
										
											2021-04-23 20:29:21 +02:00
										 |  |  |     constructor(message) { | 
					
						
							|  |  |  |         super(message); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         this.name = "ExpectationError"; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | // Use an IIFE to avoid polluting the global namespace as much as possible
 | 
					
						
							|  |  |  | (() => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     // FIXME: This is a very naive deepEquals algorithm
 | 
					
						
							|  |  |  |     const deepEquals = (a, b) => { | 
					
						
							|  |  |  |         if (Array.isArray(a)) return Array.isArray(b) && deepArrayEquals(a, b); | 
					
						
							|  |  |  |         if (typeof a === "object") return typeof b === "object" && deepObjectEquals(a, b); | 
					
						
							|  |  |  |         return Object.is(a, b); | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     const deepArrayEquals = (a, b) => { | 
					
						
							|  |  |  |         if (a.length !== b.length) return false; | 
					
						
							|  |  |  |         for (let i = 0; i < a.length; ++i) { | 
					
						
							|  |  |  |             if (!deepEquals(a[i], b[i])) return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     const deepObjectEquals = (a, b) => { | 
					
						
							|  |  |  |         if (a === null) return b === null; | 
					
						
							|  |  |  |         for (let key of Reflect.ownKeys(a)) { | 
					
						
							|  |  |  |             if (!deepEquals(a[key], b[key])) return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-27 22:17:05 +01:00
										 |  |  |     const valueToString = value => { | 
					
						
							|  |  |  |         try { | 
					
						
							| 
									
										
										
										
											2022-02-16 02:14:57 -08:00
										 |  |  |             if (value === 0 && 1 / value < 0) { | 
					
						
							|  |  |  |                 return "-0"; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-06-27 22:17:05 +01:00
										 |  |  |             return String(value); | 
					
						
							|  |  |  |         } catch { | 
					
						
							|  |  |  |             // e.g for objects without a prototype, the above throws.
 | 
					
						
							|  |  |  |             return Object.prototype.toString.call(value); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     class Expector { | 
					
						
							|  |  |  |         constructor(target, inverted) { | 
					
						
							|  |  |  |             this.target = target; | 
					
						
							|  |  |  |             this.inverted = !!inverted; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         get not() { | 
					
						
							|  |  |  |             return new Expector(this.target, !this.inverted); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBe(value) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     Object.is(this.target, value), | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                     () => | 
					
						
							|  |  |  |                         `toBe: expected _${valueToString(value)}_, got _${valueToString( | 
					
						
							|  |  |  |                             this.target | 
					
						
							|  |  |  |                         )}_`
 | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         // FIXME: Take a precision argument like jest's toBeCloseTo matcher
 | 
					
						
							|  |  |  |         toBeCloseTo(value) { | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |             this.__expect( | 
					
						
							|  |  |  |                 typeof this.target === "number", | 
					
						
							| 
									
										
										
										
											2021-04-23 20:12:10 +02:00
										 |  |  |                 () => `toBeCloseTo: expected target of type number, got ${typeof value}` | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |             ); | 
					
						
							|  |  |  |             this.__expect( | 
					
						
							|  |  |  |                 typeof value === "number", | 
					
						
							| 
									
										
										
										
											2021-04-23 20:12:10 +02:00
										 |  |  |                 () => `toBeCloseTo: expected argument of type number, got ${typeof value}` | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |             ); | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(Math.abs(this.target - value) < 0.000001); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveLength(length) { | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |             this.__expect( | 
					
						
							|  |  |  |                 typeof this.target.length === "number", | 
					
						
							|  |  |  |                 () => "toHaveLength: target.length not of type number" | 
					
						
							|  |  |  |             ); | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(Object.is(this.target.length, length)); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-09 00:08:47 +03:00
										 |  |  |         toHaveSize(size) { | 
					
						
							|  |  |  |             this.__expect( | 
					
						
							|  |  |  |                 typeof this.target.size === "number", | 
					
						
							|  |  |  |                 () => "toHaveSize: target.size not of type number" | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(Object.is(this.target.size, size)); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveProperty(property, value) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 let object = this.target; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (typeof property === "string" && property.includes(".")) { | 
					
						
							|  |  |  |                     let propertyArray = []; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     while (property.includes(".")) { | 
					
						
							|  |  |  |                         let index = property.indexOf("."); | 
					
						
							|  |  |  |                         propertyArray.push(property.substring(0, index)); | 
					
						
							|  |  |  |                         if (index + 1 >= property.length) break; | 
					
						
							|  |  |  |                         property = property.substring(index + 1, property.length); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     propertyArray.push(property); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     property = propertyArray; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (Array.isArray(property)) { | 
					
						
							|  |  |  |                     for (let key of property) { | 
					
						
							|  |  |  |                         this.__expect(object !== undefined && object !== null); | 
					
						
							|  |  |  |                         object = object[key]; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     object = object[property]; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 this.__expect(object !== undefined); | 
					
						
							|  |  |  |                 if (value !== undefined) this.__expect(deepEquals(object, value)); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeDefined() { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2021-04-23 20:12:10 +02:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target !== undefined, | 
					
						
							|  |  |  |                     () => "toBeDefined: expected target to be defined, got undefined" | 
					
						
							|  |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeInstanceOf(class_) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(this.target instanceof class_); | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeNull() { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(this.target === null); | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeUndefined() { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target === undefined, | 
					
						
							| 
									
										
										
										
											2021-04-23 20:12:10 +02:00
										 |  |  |                     () => | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                         `toBeUndefined: expected target to be undefined, got _${valueToString( | 
					
						
							| 
									
										
										
										
											2021-04-23 20:12:10 +02:00
										 |  |  |                             this.target | 
					
						
							|  |  |  |                         )}_`
 | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeNaN() { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     isNaN(this.target), | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                     () => `toBeNaN: expected target to be NaN, got _${valueToString(this.target)}_` | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeTrue() { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2021-05-13 23:34:03 +01:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target === true, | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                     () => | 
					
						
							|  |  |  |                         `toBeTrue: expected target to be true, got _${valueToString(this.target)}_` | 
					
						
							| 
									
										
										
										
											2021-05-13 23:34:03 +01:00
										 |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeFalse() { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2021-05-13 23:34:03 +01:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target === false, | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                     () => | 
					
						
							| 
									
										
										
										
											2021-06-28 18:22:42 +01:00
										 |  |  |                         `toBeFalse: expected target to be false, got _${valueToString( | 
					
						
							|  |  |  |                             this.target | 
					
						
							|  |  |  |                         )}_`
 | 
					
						
							| 
									
										
										
										
											2021-05-13 23:34:03 +01:00
										 |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         __validateNumericComparisonTypes(value) { | 
					
						
							|  |  |  |             this.__expect(typeof this.target === "number" || typeof this.target === "bigint"); | 
					
						
							|  |  |  |             this.__expect(typeof value === "number" || typeof value === "bigint"); | 
					
						
							|  |  |  |             this.__expect(typeof this.target === typeof value); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeLessThan(value) { | 
					
						
							|  |  |  |             this.__validateNumericComparisonTypes(value); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(this.target < value); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeLessThanOrEqual(value) { | 
					
						
							|  |  |  |             this.__validateNumericComparisonTypes(value); | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(this.target <= value); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeGreaterThan(value) { | 
					
						
							|  |  |  |             this.__validateNumericComparisonTypes(value); | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(this.target > value); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toBeGreaterThanOrEqual(value) { | 
					
						
							|  |  |  |             this.__validateNumericComparisonTypes(value); | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(this.target >= value); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toContain(item) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 for (let element of this.target) { | 
					
						
							|  |  |  |                     if (item === element) return; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |                 throw new ExpectationError(); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toContainEqual(item) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 for (let element of this.target) { | 
					
						
							|  |  |  |                     if (deepEquals(item, element)) return; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-07-04 10:09:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |                 throw new ExpectationError(); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toEqual(value) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(deepEquals(this.target, value)); | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toThrow(value) { | 
					
						
							|  |  |  |             this.__expect(typeof this.target === "function"); | 
					
						
							|  |  |  |             this.__expect( | 
					
						
							|  |  |  |                 typeof value === "string" || | 
					
						
							|  |  |  |                     typeof value === "function" || | 
					
						
							|  |  |  |                     typeof value === "object" || | 
					
						
							|  |  |  |                     value === undefined | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 let threw = true; | 
					
						
							|  |  |  |                 try { | 
					
						
							|  |  |  |                     this.target(); | 
					
						
							|  |  |  |                     threw = false; | 
					
						
							|  |  |  |                 } catch (e) { | 
					
						
							|  |  |  |                     if (typeof value === "string") { | 
					
						
							|  |  |  |                         this.__expect(e.message.includes(value)); | 
					
						
							|  |  |  |                     } else if (typeof value === "function") { | 
					
						
							|  |  |  |                         this.__expect(e instanceof value); | 
					
						
							|  |  |  |                     } else if (typeof value === "object") { | 
					
						
							|  |  |  |                         this.__expect(e.message === value.message); | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 this.__expect(threw); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         pass(message) { | 
					
						
							|  |  |  |             // FIXME: This does nothing. If we want to implement things
 | 
					
						
							|  |  |  |             // like assertion count, this will have to do something
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 18:09:35 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         // jest-extended
 | 
					
						
							|  |  |  |         fail(message) { | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2020-08-21 21:53:54 -04:00
										 |  |  |                 this.__expect(false, message); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         // jest-extended
 | 
					
						
							|  |  |  |         toThrowWithMessage(class_, message) { | 
					
						
							|  |  |  |             this.__expect(typeof this.target === "function"); | 
					
						
							|  |  |  |             this.__expect(class_ !== undefined); | 
					
						
							|  |  |  |             this.__expect(message !== undefined); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 try { | 
					
						
							|  |  |  |                     this.target(); | 
					
						
							| 
									
										
										
										
											2021-05-13 23:33:15 +01:00
										 |  |  |                     this.__expect(false, () => "toThrowWithMessage: target function did not throw"); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |                 } catch (e) { | 
					
						
							| 
									
										
										
										
											2021-05-11 22:41:35 +01:00
										 |  |  |                     this.__expect( | 
					
						
							|  |  |  |                         e instanceof class_, | 
					
						
							|  |  |  |                         () => | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                             `toThrowWithMessage: expected error to be instance of ${valueToString( | 
					
						
							| 
									
										
										
										
											2021-05-13 23:30:50 +01:00
										 |  |  |                                 class_.name | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                             )}, got ${valueToString(e.name)}`
 | 
					
						
							| 
									
										
										
										
											2021-05-11 22:41:35 +01:00
										 |  |  |                     ); | 
					
						
							|  |  |  |                     this.__expect( | 
					
						
							|  |  |  |                         e.message.includes(message), | 
					
						
							|  |  |  |                         () => | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                             `toThrowWithMessage: expected error message to include _${valueToString( | 
					
						
							| 
									
										
										
										
											2021-05-13 23:30:50 +01:00
										 |  |  |                                 message | 
					
						
							| 
									
										
										
										
											2021-06-16 20:44:53 +01:00
										 |  |  |                             )}_, got _${valueToString(e.message)}_`
 | 
					
						
							| 
									
										
										
										
											2021-05-11 22:41:35 +01:00
										 |  |  |                     ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |                 } | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         // Test for syntax errors; target must be a string
 | 
					
						
							|  |  |  |         toEval() { | 
					
						
							|  |  |  |             this.__expect(typeof this.target === "string"); | 
					
						
							| 
									
										
										
										
											2020-12-26 16:24:24 +01:00
										 |  |  |             const success = canParseSource(this.target); | 
					
						
							| 
									
										
										
										
											2021-11-30 01:00:06 +01:00
										 |  |  |             this.__expect( | 
					
						
							|  |  |  |                 this.inverted ? !success : success, | 
					
						
							|  |  |  |                 () => | 
					
						
							|  |  |  |                     `Expected _${valueToString(this.target)}_` + | 
					
						
							|  |  |  |                     (this.inverted ? "not to eval but it did" : "to eval but it didn't") | 
					
						
							|  |  |  |             ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         // Must compile regardless of inverted-ness
 | 
					
						
							|  |  |  |         toEvalTo(value) { | 
					
						
							|  |  |  |             this.__expect(typeof this.target === "string"); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             let result; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             try { | 
					
						
							| 
									
										
										
										
											2021-06-18 19:09:17 +01:00
										 |  |  |                 result = eval(this.target); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             } catch (e) { | 
					
						
							| 
									
										
										
										
											2021-11-30 01:00:06 +01:00
										 |  |  |                 throw new ExpectationError( | 
					
						
							|  |  |  |                     `Expected _${valueToString(this.target)}_ to eval but it failed with ${e}` | 
					
						
							|  |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							| 
									
										
										
										
											2021-11-30 01:00:06 +01:00
										 |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     deepEquals(value, result), | 
					
						
							|  |  |  |                     () => | 
					
						
							|  |  |  |                         `Expected _${valueToString(this.target)}_ to eval to ` + | 
					
						
							|  |  |  |                         `_${valueToString(value)}_ but got _${valueToString(result)}_` | 
					
						
							|  |  |  |                 ); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveConfigurableProperty(property) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             let d = Object.getOwnPropertyDescriptor(this.target, property); | 
					
						
							|  |  |  |             this.__expect(d !== undefined); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(d.configurable); | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveEnumerableProperty(property) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             let d = Object.getOwnPropertyDescriptor(this.target, property); | 
					
						
							|  |  |  |             this.__expect(d !== undefined); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(d.enumerable); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveWritableProperty(property) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             let d = Object.getOwnPropertyDescriptor(this.target, property); | 
					
						
							|  |  |  |             this.__expect(d !== undefined); | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(d.writable); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveValueProperty(property, value) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             let d = Object.getOwnPropertyDescriptor(this.target, property); | 
					
						
							|  |  |  |             this.__expect(d !== undefined); | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(d.value !== undefined); | 
					
						
							|  |  |  |                 if (value !== undefined) this.__expect(deepEquals(value, d.value)); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveGetterProperty(property) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             let d = Object.getOwnPropertyDescriptor(this.target, property); | 
					
						
							|  |  |  |             this.__expect(d !== undefined); | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(d.get !== undefined); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         toHaveSetterProperty(property) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             let d = Object.getOwnPropertyDescriptor(this.target, property); | 
					
						
							|  |  |  |             this.__expect(d !== undefined); | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect(d.set !== undefined); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 11:13:53 +01:00
										 |  |  |         toBeIteratorResultWithValue(value) { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target.done === false, | 
					
						
							|  |  |  |                     () => | 
					
						
							|  |  |  |                         `toGiveIteratorResultWithValue: expected 'done' to be _false_ got ${valueToString( | 
					
						
							|  |  |  |                             this.target.done | 
					
						
							|  |  |  |                         )}`
 | 
					
						
							|  |  |  |                 ); | 
					
						
							|  |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     deepEquals(value, this.target.value), | 
					
						
							|  |  |  |                     () => | 
					
						
							|  |  |  |                         `toGiveIteratorResultWithValue: expected 'value' to be _${valueToString( | 
					
						
							|  |  |  |                             value | 
					
						
							|  |  |  |                         )}_ got ${valueToString(this.target.value)}`
 | 
					
						
							|  |  |  |                 ); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         toBeIteratorResultDone() { | 
					
						
							|  |  |  |             this.__expect(this.target !== undefined && this.target !== null); | 
					
						
							|  |  |  |             this.__doMatcher(() => { | 
					
						
							|  |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target.done === true, | 
					
						
							|  |  |  |                     () => | 
					
						
							|  |  |  |                         `toGiveIteratorResultDone: expected 'done' to be _true_ got ${valueToString( | 
					
						
							|  |  |  |                             this.target.done | 
					
						
							|  |  |  |                         )}`
 | 
					
						
							|  |  |  |                 ); | 
					
						
							|  |  |  |                 this.__expect( | 
					
						
							|  |  |  |                     this.target.value === undefined, | 
					
						
							|  |  |  |                     () => | 
					
						
							|  |  |  |                         `toGiveIteratorResultDone: expected 'value' to be _undefined_ got ${valueToString( | 
					
						
							|  |  |  |                             this.target.value | 
					
						
							|  |  |  |                         )}`
 | 
					
						
							|  |  |  |                 ); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         __doMatcher(matcher) { | 
					
						
							|  |  |  |             if (!this.inverted) { | 
					
						
							|  |  |  |                 matcher(); | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 let threw = false; | 
					
						
							|  |  |  |                 try { | 
					
						
							|  |  |  |                     matcher(); | 
					
						
							|  |  |  |                 } catch (e) { | 
					
						
							|  |  |  |                     if (e.name === "ExpectationError") threw = true; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-21 21:53:54 -04:00
										 |  |  |                 if (!threw) throw new ExpectationError("not: test didn't fail"); | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-21 21:53:54 -04:00
										 |  |  |         __expect(value, details) { | 
					
						
							|  |  |  |             if (value !== true) { | 
					
						
							| 
									
										
										
										
											2020-11-11 22:01:33 +00:00
										 |  |  |                 if (details !== undefined) { | 
					
						
							|  |  |  |                     throw new ExpectationError(details()); | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     throw new ExpectationError(); | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2020-08-21 21:53:54 -04:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     expect = value => new Expector(value); | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     // describe is able to lump test results inside of it by using this context
 | 
					
						
							|  |  |  |     // variable. Top level tests have the default suite message
 | 
					
						
							|  |  |  |     const defaultSuiteMessage = "__$$TOP_LEVEL$$__"; | 
					
						
							|  |  |  |     let suiteMessage = defaultSuiteMessage; | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     describe = (message, callback) => { | 
					
						
							|  |  |  |         suiteMessage = message; | 
					
						
							| 
									
										
										
										
											2021-06-04 03:23:33 +04:30
										 |  |  |         if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {}; | 
					
						
							|  |  |  |         try { | 
					
						
							|  |  |  |             callback(); | 
					
						
							|  |  |  |         } catch (e) { | 
					
						
							|  |  |  |             __TestResults__[suiteMessage][defaultSuiteMessage] = { | 
					
						
							|  |  |  |                 result: "fail", | 
					
						
							|  |  |  |                 details: String(e), | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         suiteMessage = defaultSuiteMessage; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test = (message, callback) => { | 
					
						
							|  |  |  |         if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const suite = __TestResults__[suiteMessage]; | 
					
						
							| 
									
										
										
										
											2021-05-05 15:54:39 +01:00
										 |  |  |         if (Object.prototype.hasOwnProperty.call(suite, message)) { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             suite[message] = { | 
					
						
							|  |  |  |                 result: "fail", | 
					
						
							| 
									
										
										
										
											2021-03-31 22:21:36 +02:00
										 |  |  |                 details: "Another test with the same message did already run", | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-03 23:13:06 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         try { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             callback(); | 
					
						
							|  |  |  |             suite[message] = { | 
					
						
							|  |  |  |                 result: "pass", | 
					
						
							|  |  |  |             }; | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |         } catch (e) { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             suite[message] = { | 
					
						
							|  |  |  |                 result: "fail", | 
					
						
							| 
									
										
										
										
											2020-08-21 21:53:54 -04:00
										 |  |  |                 details: String(e), | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |             }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     test.skip = (message, callback) => { | 
					
						
							|  |  |  |         if (typeof callback !== "function") | 
					
						
							|  |  |  |             throw new Error("test.skip has invalid second argument (must be a function)"); | 
					
						
							| 
									
										
										
										
											2020-07-04 12:57:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         if (!__TestResults__[suiteMessage]) __TestResults__[suiteMessage] = {}; | 
					
						
							| 
									
										
										
										
											2020-07-04 12:57:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         const suite = __TestResults__[suiteMessage]; | 
					
						
							| 
									
										
										
										
											2021-05-05 15:54:39 +01:00
										 |  |  |         if (Object.prototype.hasOwnProperty.call(suite, message)) { | 
					
						
							|  |  |  |             suite[message] = { | 
					
						
							|  |  |  |                 result: "fail", | 
					
						
							|  |  |  |                 details: "Another test with the same message did already run", | 
					
						
							|  |  |  |             }; | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-07-04 12:57:12 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |         suite[message] = { | 
					
						
							|  |  |  |             result: "skip", | 
					
						
							|  |  |  |         }; | 
					
						
							| 
									
										
										
										
											2020-07-05 09:27:00 -07:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-07-03 14:36:58 -07:00
										 |  |  | })(); |