|
1 | 1 | from pathlib import Path |
2 | 2 |
|
3 | 3 | import pytest |
4 | | -from sanic import Sanic |
| 4 | +from servestatic import ServeStaticASGI |
5 | 5 |
|
6 | 6 | import reactpy |
7 | | -from reactpy.asgi import sanic as sanic_implementation |
| 7 | +from reactpy.asgi.standalone import ReactPy |
8 | 8 | from reactpy.testing import ( |
9 | 9 | BackendFixture, |
10 | 10 | DisplayFixture, |
@@ -50,27 +50,20 @@ def ShowCurrentComponent(): |
50 | 50 | await display.page.wait_for_selector("#unmount-flag", state="attached") |
51 | 51 |
|
52 | 52 |
|
53 | | -@pytest.mark.flaky(reruns=3) |
54 | 53 | async def test_module_from_url(browser): |
55 | | - app = Sanic("test_module_from_url") |
56 | | - |
57 | | - # instead of directing the URL to a CDN, we just point it to this static file |
58 | | - app.static( |
59 | | - "/simple-button.js", |
60 | | - str(JS_FIXTURES_DIR / "simple-button.js"), |
61 | | - content_type="text/javascript", |
62 | | - ) |
63 | | - |
64 | 54 | SimpleButton = reactpy.web.export( |
65 | | - reactpy.web.module_from_url("/simple-button.js", resolve_exports=False), |
| 55 | + reactpy.web.module_from_url("/static/simple-button.js", resolve_exports=False), |
66 | 56 | "SimpleButton", |
67 | 57 | ) |
68 | 58 |
|
69 | 59 | @reactpy.component |
70 | 60 | def ShowSimpleButton(): |
71 | 61 | return SimpleButton({"id": "my-button"}) |
72 | 62 |
|
73 | | - async with BackendFixture(app=app, implementation=sanic_implementation) as server: |
| 63 | + app = ReactPy(ShowSimpleButton) |
| 64 | + app = ServeStaticASGI(app, JS_FIXTURES_DIR, "/static/") |
| 65 | + |
| 66 | + async with BackendFixture(app) as server: |
74 | 67 | async with DisplayFixture(server, browser) as display: |
75 | 68 | await display.show(ShowSimpleButton) |
76 | 69 |
|
|
0 commit comments