| 
									
										
										
										
											2024-11-25 22:51:47 +08:00
										 |  |  | import * as pureStyle from "./style.css"; | 
					
						
							|  |  |  | import * as styles from "./style.modules.css"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | it("should work", done => { | 
					
						
							| 
									
										
										
										
											2025-04-06 20:53:42 +08:00
										 |  |  | 	expect(pureStyle).toEqual({}); | 
					
						
							| 
									
										
										
										
											2024-11-25 22:51:47 +08:00
										 |  |  | 	const style = getComputedStyle(document.body); | 
					
						
							|  |  |  | 	expect(style.getPropertyValue("background")).toBe(" red"); | 
					
						
							|  |  |  |   expect(styles.foo).toBe('_style_modules_css-foo'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	import(/* webpackPrefetch: true */ "./style2.css").then(x => { | 
					
						
							| 
									
										
										
										
											2025-04-06 20:53:42 +08:00
										 |  |  | 		expect(x).toEqual({}); | 
					
						
							| 
									
										
										
										
											2024-11-25 22:51:47 +08:00
										 |  |  | 		const style = getComputedStyle(document.body); | 
					
						
							|  |  |  | 		expect(style.getPropertyValue("color")).toBe(" blue"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		import(/* webpackPrefetch: true */ "./style2.modules.css").then(x => { | 
					
						
							|  |  |  | 		  expect(x.bar).toBe("_style2_modules_css-bar"); | 
					
						
							|  |  |  | 			done(); | 
					
						
							|  |  |  | 		}, done); | 
					
						
							|  |  |  | 	}, done); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | it("should work in worker", async () => { | 
					
						
							|  |  |  | 	const worker = new Worker(new URL("./worker.js", import.meta.url), { | 
					
						
							|  |  |  | 		type: "module" | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	worker.postMessage("ok"); | 
					
						
							|  |  |  | 	const result = await new Promise(resolve => { | 
					
						
							|  |  |  | 		worker.onmessage = event => { | 
					
						
							|  |  |  | 			resolve(event.data); | 
					
						
							|  |  |  | 		}; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	expect(result).toBe("data: _style_modules_css-foo _style2_modules_css-bar _style3_modules_css-baz, thanks"); | 
					
						
							|  |  |  | 	await worker.terminate(); | 
					
						
							|  |  |  | }); |