Skip to content

Storage Examples

Brandon Correa edited this page May 17, 2024 · 1 revision

In Your Tests

(ns acme.mimic)

(defn set-theme! [theme]
  (js-invoke js/localStorage "setItem" "theme" theme))
(ns acme.mimic-spec
  (:require [acme.mimic :as sut]
            [bwa.mimic.spec-helper :as spec-helper]
            [speclj.core :refer-macros [describe it should=]]))

(describe "Mimic"
  (spec-helper/with-memory-local-storage)

  (it "sets the theme to light or dark mode"
    (sut/set-theme! "light")
    (should= "light" (js-invoke js/localStorage "getItem" "theme"))
    (sut/set-theme! "dark")
    (should= "dark" (js-invoke js/localStorage "getItem" "theme")))
  )
Clone this wiki locally