Skip to content

Commit

Permalink
Restore usages, as they will be supported in a future release of speclj
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoncorrea committed May 28, 2024
1 parent ca565f8 commit b0eb447
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
7 changes: 3 additions & 4 deletions spec/cljs/bwa/mimic/memory_server_spec.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns bwa.mimic.memory-server-spec
(:require-macros [speclj.core :refer [before context describe it should should-be-nil should-contain should-have-invoked should-not-have-invoked should-throw should= stub with-stubs]])
(:require-macros [speclj.core :refer [context describe it should should-be-nil should-contain should-have-invoked should-not-have-invoked should-throw should= stub with with-stubs]])
(:require [bwa.mimic.server :as server]
[bwa.mimic.spec-helper :as spec-helper]
[bwa.mimic.spec-helperc :as spec-helperc]
Expand All @@ -19,16 +19,15 @@
(wjs/o-set sock "addEventListener" (->add-event-listener sock))
sock))

(def sock (atom nil))
(declare sock)

(describe "Memory Server"
(with-stubs)
(spec-helperc/capture-logs-around)
(spec-helper/with-memory-websockets)
(spec-helper/stub-performance-now 123.4567)

;; TODO [BAC]: (with sock ...) once speclj advanced `with` issue is resolved
(before (reset! sock (js/WebSocket. "ws://example.com")))
(with sock (js/WebSocket. "ws://example.com"))

(it "connections"
(should= [@sock] (server/connections))
Expand Down
7 changes: 3 additions & 4 deletions spec/cljs/bwa/mimic/memory_storage_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[bwa.mimic.memory-storage :as sut]
[bwa.mimic.spec-helper :as spec-helper]
[c3kit.wire.js :as wjs]
[speclj.core :refer-macros [context before should-not= describe should-not-throw should-be-a it should= should-be-nil should-fail]]))
[speclj.core :refer-macros [context should-not= describe should-not-throw should-be-a it should= should-be-nil should-fail with]]))

(def js-local-storage
{:get-item (wjs/o-get js/localStorage "getItem")
Expand All @@ -19,7 +19,7 @@
:clear (wjs/o-get js/sessionStorage "clear")
})

(def store (atom nil))
(declare store)
(defn repeat-str [s n] (js-invoke s "repeat" n))
(defn o-keys [obj] (js->clj (sut/o-keys obj)))
(defn o-values [obj] (js->clj (js-invoke js/Object "values" obj)))
Expand All @@ -29,8 +29,7 @@

(context "API"

;; TODO [BAC]: (with store ...) once speclj advanced `with` issue is resolved
(before (reset! store (sut/->MemStorage)))
(with store (sut/->MemStorage))

(it "initialized"
(should-be-a js/Object @store)
Expand Down
7 changes: 3 additions & 4 deletions spec/cljs/bwa/mimic/memory_websocket_spec.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns bwa.mimic.memory-websocket-spec
(:require-macros [speclj.core :refer [before context describe it redefs-around should-contain should-have-invoked should-not-have-invoked should-not-throw should-throw should= stub with-stubs]])
(:require-macros [speclj.core :refer [before context describe it redefs-around should-contain should-have-invoked should-not-have-invoked should-not-throw should-throw should= stub with-stubs with]])
(:require [bwa.mimic.event :as event]
[bwa.mimic.memory-websocket :as sut]
[bwa.mimic.server :as server]
Expand All @@ -11,7 +11,7 @@
[clojure.string :as str]
[speclj.stub :as stub]))

(def sock (atom nil))
(declare sock)

(defn should-have-invoked-close-event
([name sock code reason] (should-have-invoked-close-event name sock code reason true))
Expand Down Expand Up @@ -39,8 +39,7 @@
(spec-helperc/capture-logs-around)
(spec-helper/stub-performance-now 123.4567)

;; TODO [BAC]: (with sock ...) once speclj advanced `with` issue is resolved
(before (reset! sock (sut/->MemSocket "ws://example.com/foo")))
(with sock (sut/->MemSocket "ws://example.com/foo"))

(redefs-around [server/initiate (stub :server/initiate)])

Expand Down
5 changes: 2 additions & 3 deletions spec/cljs/bwa/mimic/ws_interceptor_spec.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[c3kit.wire.js :as wjs]
[speclj.core]))

(def sock (atom nil))
(declare sock)

(describe "WebSocket Interceptor"
(with-stubs)
Expand Down Expand Up @@ -42,8 +42,7 @@
(context "events"
(spec-helper/with-websocket-impl sut/->WebSocketInterceptor)

;; TODO [BAC]: (with sock ...) once speclj advanced `with` issue is resolved
(before (reset! sock (js/WebSocket. "ws://localhost:8080")))
(with sock (js/WebSocket. "ws://localhost:8080"))

(it "message"
(let [event (event/->MessageEvent @sock "blah")]
Expand Down

0 comments on commit b0eb447

Please sign in to comment.