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

28 lines
1000 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
spec = beforeAll (Pup.launch_ =<< Pup.puppeteer unit)
$ 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
pup <- Pup.puppeteer unit
b' <- Pup.connect (Pup.connectDefault $ Pup.BrowserWebsocket ws) pup
Pup.Browser.close b'