| 
									
										
										
										
											2021-11-10 09:22:09 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const ArrayHelpers = require("../lib/util/ArrayHelpers"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | describe("ArrayHelpers", () => { | 
					
						
							|  |  |  | 	it("groupBy should partition into two arrays", () => { | 
					
						
							|  |  |  | 		expect( | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 			ArrayHelpers.groupBy([1, 2, 3, 4, 5, 6], (x) => x % 2 === 0) | 
					
						
							| 
									
										
										
										
											2021-11-10 09:22:09 +08:00
										 |  |  | 		).toStrictEqual([ | 
					
						
							|  |  |  | 			[2, 4, 6], | 
					
						
							|  |  |  | 			[1, 3, 5] | 
					
						
							|  |  |  | 		]); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-10 09:22:09 +08:00
										 |  |  | 	it("groupBy works with empty array", () => { | 
					
						
							| 
									
										
										
										
											2025-07-17 00:13:14 +08:00
										 |  |  | 		expect(ArrayHelpers.groupBy([], (x) => x % 2 === 0)).toStrictEqual([ | 
					
						
							|  |  |  | 			[], | 
					
						
							|  |  |  | 			[] | 
					
						
							|  |  |  | 		]); | 
					
						
							| 
									
										
										
										
											2021-11-10 09:22:09 +08:00
										 |  |  | 	}); | 
					
						
							|  |  |  | }); |