* @param runes runes mode * @param fn A function that returns a function because we first need to set up all the signals * and then execute the test in order to simulate a real component
(runes: boolean, fn: (runes: boolean) => () => void)
| 25 | * and then execute the test in order to simulate a real component |
| 26 | */ |
| 27 | function run_test(runes: boolean, fn: (runes: boolean) => () => void) { |
| 28 | return () => { |
| 29 | // Create a component context to test runes vs legacy mode |
| 30 | push({}, runes); |
| 31 | // Create a render context so that effect validations etc don't fail |
| 32 | let execute: any; |
| 33 | const destroy = effect_root(() => { |
| 34 | execute = fn(runes); |
| 35 | }); |
| 36 | pop(); |
| 37 | execute(); |
| 38 | destroy(); |
| 39 | }; |
| 40 | } |
| 41 | |
| 42 | function test(text: string, fn: (runes: boolean) => any) { |
| 43 | it(`${text} (legacy mode)`, run_test(false, fn)); |