aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorClombrong <clombrong@egregore.fun>2025-04-24 16:22:03 +0200
committerClombrong <cromblong@egregore.fun>2025-04-24 16:22:03 +0200
commit1db20a50974dd33874d28aa78f69a25aa4294a94 (patch)
treed2b24d2801fdd21001cdd7bc2da6ecad65724d2e /test
parent9c36f4089d4636f37853d0c13d6a6ca2f4fd6b05 (diff)
fix: rearrange all portals under common portal/ folder
Diffstat (limited to 'test')
-rw-r--r--test/js/dune14
-rw-r--r--test/js/package-lock.json21
-rw-r--r--test/js/package.json5
-rw-r--r--test/js/polyfill.js1
-rw-r--r--test/js/websockets_hello.ml35
5 files changed, 0 insertions, 76 deletions
diff --git a/test/js/dune b/test/js/dune
deleted file mode 100644
index b34c980..0000000
--- a/test/js/dune
+++ /dev/null
@@ -1,14 +0,0 @@
-(test
- (name websockets_hello)
- (libraries portal_ws lwt js_of_ocaml)
- (modes js)
- (preprocess (pps js_of_ocaml-ppx))
- (deps node_modules)
- (js_of_ocaml
- (javascript_files polyfill.js)))
-
-(rule
- (alias npm)
- (target node_modules)
- (deps package.json package-lock.json)
- (action (system "npm ci")))
diff --git a/test/js/package-lock.json b/test/js/package-lock.json
deleted file mode 100644
index 8b5d148..0000000
--- a/test/js/package-lock.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "js",
- "lockfileVersion": 3,
- "requires": true,
- "packages": {
- "": {
- "dependencies": {
- "xmlhttprequest": "^1.8.0"
- }
- },
- "node_modules/xmlhttprequest": {
- "version": "1.8.0",
- "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz",
- "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==",
- "license": "MIT",
- "engines": {
- "node": ">=0.4.0"
- }
- }
- }
-}
diff --git a/test/js/package.json b/test/js/package.json
deleted file mode 100644
index 3b36bf4..0000000
--- a/test/js/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "dependencies": {
- "xmlhttprequest": "^1.8.0"
- }
-}
diff --git a/test/js/polyfill.js b/test/js/polyfill.js
deleted file mode 100644
index e394ec8..0000000
--- a/test/js/polyfill.js
+++ /dev/null
@@ -1 +0,0 @@
-global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
diff --git a/test/js/websockets_hello.ml b/test/js/websockets_hello.ml
deleted file mode 100644
index fa47965..0000000
--- a/test/js/websockets_hello.ml
+++ /dev/null
@@ -1,35 +0,0 @@
-open Lwt.Syntax
-open Js_of_ocaml
-
-(* https://stackoverflow.com/questions/34929382/what-are-the-differences-between-lwt-async-and-lwt-main-run-on-ocaml-node-js *)
-let rec run t =
- let next_tick (_callback : unit -> unit) =
- Js.Unsafe.(fun_call
- (js_expr "process.nextTick")
- [| inject (Js.wrap_callback _callback) |])
- in Lwt.wakeup_paused ();
- match Lwt.poll t with
- | Some x -> x
- | None ->
- if Lwt.paused_count () > 0
- then next_tick (fun () -> run t)
- else ()
-
-let () =
- run @@
- let* server = Portal_ws.ws_endpoint "telepath.im" in
- let stream, push =
- (* Echo is a websocket that... echoes you stuff. *)
- Portal_ws.ws_stream "wss://echo.websocket.org" in
- push (Some "great text");
- push (Some "other text");
- push (Some "yet another text");
- push (Some "BYE");
- let+ _ = Lwt_stream.iter
- (fun greetings ->
- match greetings with
- (* When the websocket sends "BYE", we close. *)
- | "BYE" -> print_endline "CLOSING BYE"; push None
- | hello -> print_endline ("> " ^ hello))
- stream
- in print_endline server