|
1 | 1 | module Test.DOM.HTML.Window where |
2 | 2 |
|
3 | | -import Prelude (Unit, bind, (<<<), discard) |
| 3 | +import Prelude |
| 4 | + |
| 5 | +import Control.Monad.Eff.Class (liftEff) |
4 | 6 | import DOM (DOM) |
5 | 7 | import DOM.HTML (window) |
6 | 8 | import DOM.HTML.Types (WINDOW) |
7 | | -import DOM.HTML.Window |
8 | | -import Control.Monad.Free (Free) |
9 | | -import Control.Monad.Aff (Aff) |
10 | | -import Control.Monad.Aff.Console (CONSOLE) |
11 | | -import Control.Monad.Eff (Eff) |
12 | | -import Control.Monad.Eff.Class (liftEff) as EffClass |
13 | | -import Test.Unit (TestF, describe, it) |
14 | | -import Test.Unit.Assert (shouldEqual) |
| 9 | +import DOM.HTML.Window as Window |
15 | 10 | import Data.Maybe (isJust) |
16 | | -import Data.Traversable (class Traversable, sequence) |
17 | | - |
18 | | - |
19 | | -liftEff :: forall eff a. Eff eff a -> Aff eff a |
20 | | -liftEff = EffClass.liftEff |
21 | | - |
22 | | -liftSeq :: forall eff m a. Traversable m => m (Eff eff a) -> Aff eff (m a) |
23 | | -liftSeq = liftEff <<< sequence |
| 11 | +import Test.Unit (TestSuite, describe, it) |
| 12 | +import Test.Unit.Assert (shouldEqual) |
24 | 13 |
|
25 | | -domHtmlWindowTests |
26 | | - :: forall eff. Free (TestF (dom :: DOM, console :: CONSOLE, window :: WINDOW | eff)) Unit |
| 14 | +domHtmlWindowTests :: forall eff. TestSuite (dom :: DOM, window :: WINDOW | eff) |
27 | 15 | domHtmlWindowTests = do |
28 | 16 | describe "innerHeight" do |
29 | 17 | it "should return the default inner height" do |
30 | | - windowHeight <- liftEff do |
31 | | - window' <- window |
32 | | - innerHeight window' |
| 18 | + windowHeight <- liftEff $ Window.innerHeight =<< window |
33 | 19 | windowHeight `shouldEqual` 300 |
34 | 20 |
|
35 | 21 | describe "innerWidth" do |
36 | 22 | it "should return the default inner width" do |
37 | | - windowWidth <- liftEff do |
38 | | - window' <- window |
39 | | - innerWidth window' |
| 23 | + windowWidth <- liftEff $ Window.innerWidth =<< window |
40 | 24 | windowWidth `shouldEqual` 400 |
41 | 25 |
|
42 | 26 | describe "screenX" do |
43 | 27 | it "should get the X coordinate of the window" do |
44 | | - x <- liftEff do |
45 | | - window' <- window |
46 | | - screenX window' |
| 28 | + x <- liftEff $ Window.screenX =<< window |
47 | 29 | x `shouldEqual` 0 |
48 | 30 |
|
49 | 31 | describe "screenY" do |
50 | 32 | it "should get the Y coordinate of the window" do |
51 | | - y <- liftEff do |
52 | | - window' <- window |
53 | | - screenY window' |
| 33 | + y <- liftEff $ Window.screenY =<< window |
54 | 34 | y `shouldEqual` 0 |
55 | 35 |
|
56 | 36 | describe "open" do |
57 | 37 | it "should open a new window" do |
58 | | - newWindow' <- liftEff do |
59 | | - window' <- window |
60 | | - open "about:blank" "foobar" "" window' |
| 38 | + newWindow' <- liftEff $ Window.open "about:blank" "foobar" "" =<< window |
61 | 39 | isJust newWindow' `shouldEqual` true |
0 commit comments