purescript-puppeteer/test/Puppeteer.Browser.Spec.purs

28 lines
978 B
Haskell
Raw Normal View History

2023-09-29 05:14:09 +00:00
module Puppeteer.Browser.Spec where
import Prelude
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Puppeteer as Pup
import Puppeteer.Browser as Pup.Browser
2023-09-29 22:32:24 +00:00
import Test.Spec (SpecT, afterAll, beforeAll, describe)
2023-09-29 05:14:09 +00:00
import Test.Spec.Assertions (shouldEqual, shouldNotEqual)
import Test.Util (test, testE)
spec :: SpecT Aff Unit Effect Unit
2023-10-03 21:25:12 +00:00
spec = beforeAll (Pup.launch_ =<< Pup.new)
2023-09-29 05:14:09 +00:00
$ describe "Browser" do
testE "websocketEndpoint" $ shouldNotEqual "" <=< Pup.Browser.websocketEndpoint
testE "connected" $ shouldEqual true <=< Pup.Browser.connected
test "disconnect and close" $ \b -> do
ws <- liftEffect $ Pup.Browser.websocketEndpoint b
liftEffect $ Pup.Browser.disconnect b
connected <- liftEffect $ Pup.Browser.connected b
connected `shouldEqual` false
2023-10-03 21:25:12 +00:00
pup <- Pup.new
2023-09-29 05:14:09 +00:00
b' <- Pup.connect (Pup.connectDefault $ Pup.BrowserWebsocket ws) pup
Pup.Browser.close b'