| 
									
										
										
										
											2020-07-05 10:47:40 -07:00
										 |  |  | test("throw literal", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     try { | 
					
						
							|  |  |  |         throw 1; | 
					
						
							|  |  |  |         expect().fail(); | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |         if (e.name === "ExpectationError") throw e; | 
					
						
							|  |  |  |         expect(e).toBe(1); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-05 10:47:40 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-04-13 10:31:13 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 10:47:40 -07:00
										 |  |  | test("throw array", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     try { | 
					
						
							|  |  |  |         throw [99]; | 
					
						
							|  |  |  |         expect().fail(); | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |         if (e.name === "ExpectationError") throw e; | 
					
						
							|  |  |  |         expect(e).toEqual([99]); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-05 10:47:40 -07:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-03-25 16:09:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-05 10:47:40 -07:00
										 |  |  | test("call function that throws", () => { | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     function foo() { | 
					
						
							|  |  |  |         throw "hello"; | 
					
						
							|  |  |  |         expect().fail(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-03-25 16:09:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-06 07:37:45 -07:00
										 |  |  |     try { | 
					
						
							|  |  |  |         foo(); | 
					
						
							|  |  |  |         expect().fail(); | 
					
						
							|  |  |  |     } catch (e) { | 
					
						
							|  |  |  |         if (e.name === "ExpectationError") throw e; | 
					
						
							|  |  |  |         expect(e).toBe("hello"); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-05 10:47:40 -07:00
										 |  |  | }); |