mockStaticFS creates a minimal embedded FS for testing.
()
| 11 | |
| 12 | // mockStaticFS creates a minimal embedded FS for testing. |
| 13 | func mockStaticFS() fstest.MapFS { |
| 14 | return fstest.MapFS{ |
| 15 | "static/dist/index.html": &fstest.MapFile{ |
| 16 | Data: []byte(`<!DOCTYPE html> |
| 17 | <html> |
| 18 | <head> |
| 19 | <meta charset="UTF-8"> |
| 20 | <title>taskmd</title> |
| 21 | <script type="module" crossorigin src="/assets/index-abc123.js"></script> |
| 22 | <link rel="stylesheet" crossorigin href="/assets/index-abc123.css"> |
| 23 | </head> |
| 24 | <body> |
| 25 | <div id="root"></div> |
| 26 | </body> |
| 27 | </html>`), |
| 28 | }, |
| 29 | "static/dist/assets/index-abc123.js": &fstest.MapFile{ |
| 30 | Data: []byte(`console.log("app")`), |
| 31 | }, |
| 32 | "static/dist/assets/index-abc123.css": &fstest.MapFile{ |
| 33 | Data: []byte(`body { margin: 0; }`), |
| 34 | }, |
| 35 | "static/dist/favicon.ico": &fstest.MapFile{ |
| 36 | Data: []byte("icon"), |
| 37 | }, |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // exportWithMockFS runs Export after temporarily replacing StaticFiles. |
| 42 | // Since StaticFiles() returns an empty FS in non-embed builds, we |