Skip to content

Commit 1795b1a

Browse files
authored
Merge pull request #79 from garyb/bump-dependencies
Update dependencies
2 parents 7048b49 + c7f5c7c commit 1795b1a

File tree

4 files changed

+47
-53
lines changed

4 files changed

+47
-53
lines changed

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"package.json"
2424
],
2525
"dependencies": {
26-
"purescript-aff": "^1.0.0",
26+
"purescript-aff": "^1.1.0",
2727
"purescript-argonaut-core": "^1.0.0",
2828
"purescript-arraybuffer-types": "^0.2.0",
29-
"purescript-dom": "^1.0.0",
29+
"purescript-dom": "^2.0.0",
3030
"purescript-foreign": "^1.0.0",
3131
"purescript-form-urlencoded": "^1.0.0",
3232
"purescript-http-methods": "^1.0.0",
33-
"purescript-integers": "^1.0.0",
33+
"purescript-integers": "^1.1.0",
3434
"purescript-math": "^2.0.0",
3535
"purescript-media-types": "^1.0.0",
3636
"purescript-nullable": "^1.0.1",

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"test": "jshint src && jscs src && pulp test"
77
},
88
"devDependencies": {
9-
"body-parser": "^1.13.2",
10-
"express": "^4.13.1",
11-
"jscs": "^2.8.0",
12-
"jshint": "^2.9.1",
9+
"body-parser": "^1.15.2",
10+
"express": "^4.14.0",
11+
"jscs": "^3.0.7",
12+
"jshint": "^2.9.2",
1313
"pulp": "^9.0.1",
14-
"purescript": "^0.9.1",
14+
"purescript": "^0.9.2",
1515
"purescript-psa": "^0.3.9",
16-
"rimraf": "^2.5.2",
16+
"rimraf": "^2.5.4",
1717
"xhr2": "^0.1.3"
1818
}
1919
}

test/Main.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
1+
"use strict";
22

3-
// module Test.Main
4-
5-
exports.logAny = function(a){
3+
exports.logAny = function (a) {
64
return function () {
75
console.log(a);
86
return {};
97
};
10-
}
8+
};

test/Main.purs

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,34 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Bind
6-
import Control.Monad.Aff
7-
import Control.Monad.Aff.AVar (AVAR())
5+
import Control.Monad.Aff (Aff, cancel, forkAff, attempt, runAff, makeAff)
6+
import Control.Monad.Aff.AVar (AVAR)
87
import Control.Monad.Aff.Console as A
9-
import Control.Monad.Eff
10-
import Control.Monad.Eff.Class
11-
import Control.Monad.Eff.Console (CONSOLE(), log, logShow)
12-
import Control.Monad.Eff.Exception
13-
import Control.Monad.Eff.Ref (REF())
8+
import Control.Monad.Eff (Eff)
9+
import Control.Monad.Eff.Class (liftEff)
10+
import Control.Monad.Eff.Console (CONSOLE, log, logShow)
11+
import Control.Monad.Eff.Exception (EXCEPTION, error, throwException)
12+
import Control.Monad.Eff.Ref (REF)
1413

15-
import Data.Either
16-
import Data.Foreign
17-
import Data.Maybe
14+
import Data.Either (Either(..))
15+
import Data.Foreign (Foreign, unsafeFromForeign)
16+
import Data.Maybe (Maybe(..))
1817

19-
import Network.HTTP.Affjax
20-
import Network.HTTP.StatusCode
18+
import Network.HTTP.Affjax as AX
19+
import Network.HTTP.StatusCode (StatusCode(..))
2120

22-
foreign import logAny
23-
:: forall e a. a -> Eff (console :: CONSOLE | e) Unit
21+
foreign import logAny :: forall e a. a -> Eff (console :: CONSOLE | e) Unit
2422

2523
logAny' :: forall e a. a -> Assert e Unit
2624
logAny' = liftEff <<< logAny
2725

28-
type Assert e a = Aff (err :: EXCEPTION, console :: CONSOLE, ajax :: AJAX | e) a
26+
type Assert e a = Aff (err :: EXCEPTION, console :: CONSOLE, ajax :: AX.AJAX | e) a
2927

3028
assertFail :: forall e a. String -> Assert e a
31-
assertFail msg = let e = error msg
32-
in makeAff \errback _ -> errback e
29+
assertFail msg = makeAff \errback _ -> errback (error msg)
3330

3431
assertMsg :: forall e. String -> Boolean -> Assert e Unit
35-
assertMsg _ true = pure unit
32+
assertMsg _ true = pure unit
3633
assertMsg msg false = assertFail msg
3734

3835
assertRight :: forall e a b. Either a b -> Assert e b
@@ -46,9 +43,8 @@ assertLeft x = case x of
4643
Left y -> pure y
4744

4845
assertEq :: forall e a. (Eq a, Show a) => a -> a -> Assert e Unit
49-
assertEq x y = if x == y
50-
then pure unit
51-
else assertFail $ "Expected " <> show x <> ", got " <> show y
46+
assertEq x y =
47+
when (x /= y) $ assertFail $ "Expected " <> show x <> ", got " <> show y
5248

5349
-- | For helping type inference
5450
typeIs :: forall e a. a -> Assert e Unit
@@ -62,7 +58,7 @@ type MainEffects e =
6258
| e
6359
)
6460

65-
main :: Eff (MainEffects (ajax :: AJAX)) Unit
61+
main :: Eff (MainEffects (ajax :: AX.AJAX)) Unit
6662
main = void $ runAff (\e -> logShow e >>= \_ -> throwException e) (const $ log "affjax: All good!") $ do
6763
let ok200 = StatusCode 200
6864
let notFound404 = StatusCode 404
@@ -72,52 +68,52 @@ main = void $ runAff (\e -> logShow e >>= \_ -> throwException e) (const $ log "
7268
let mirror = prefix "/mirror"
7369
let doesNotExist = prefix "/does-not-exist"
7470
let notJson = prefix "/not-json"
75-
let retryPolicy = defaultRetryPolicy { timeout = Just 500, shouldRetryWithStatusCode = \_ -> true }
71+
let retryPolicy = AX.defaultRetryPolicy { timeout = Just 500, shouldRetryWithStatusCode = \_ -> true }
7672

7773
A.log "GET /does-not-exist: should be 404 Not found after retries"
78-
(attempt $ retry retryPolicy affjax $ defaultRequest { url = doesNotExist }) >>= assertRight >>= \res -> do
79-
typeIs (res :: AffjaxResponse String)
74+
(attempt $ AX.retry retryPolicy AX.affjax $ AX.defaultRequest { url = doesNotExist }) >>= assertRight >>= \res -> do
75+
typeIs (res :: AX.AffjaxResponse String)
8076
assertEq notFound404 res.status
8177

8278
A.log "GET /mirror: should be 200 OK"
83-
(attempt $ affjax $ defaultRequest { url = mirror }) >>= assertRight >>= \res -> do
84-
typeIs (res :: AffjaxResponse Foreign)
79+
(attempt $ AX.affjax $ AX.defaultRequest { url = mirror }) >>= assertRight >>= \res -> do
80+
typeIs (res :: AX.AffjaxResponse Foreign)
8581
assertEq ok200 res.status
8682

8783
A.log "GET /does-not-exist: should be 404 Not found"
88-
(attempt $ affjax $ defaultRequest { url = doesNotExist }) >>= assertRight >>= \res -> do
89-
typeIs (res :: AffjaxResponse String)
84+
(attempt $ AX.affjax $ AX.defaultRequest { url = doesNotExist }) >>= assertRight >>= \res -> do
85+
typeIs (res :: AX.AffjaxResponse String)
9086
assertEq notFound404 res.status
9187

9288
A.log "GET /not-json: invalid JSON with Foreign response should throw an error"
93-
assertLeft =<< attempt (get doesNotExist :: Affjax (MainEffects ()) Foreign)
89+
assertLeft =<< attempt (AX.get doesNotExist :: AX.Affjax (MainEffects ()) Foreign)
9490

9591
A.log "GET /not-json: invalid JSON with String response should be ok"
96-
(attempt $ get notJson) >>= assertRight >>= \res -> do
97-
typeIs (res :: AffjaxResponse String)
92+
(attempt $ AX.get notJson) >>= assertRight >>= \res -> do
93+
typeIs (res :: AX.AffjaxResponse String)
9894
assertEq ok200 res.status
9995

10096
A.log "POST /mirror: should use the POST method"
101-
(attempt $ post mirror "test") >>= assertRight >>= \res -> do
97+
(attempt $ AX.post mirror "test") >>= assertRight >>= \res -> do
10298
assertEq ok200 res.status
10399
assertEq "POST" (_.method $ unsafeFromForeign res.response)
104100

105101
A.log "PUT with a request body"
106102
let content = "the quick brown fox jumps over the lazy dog"
107-
(attempt $ put mirror content) >>= assertRight >>= \res -> do
108-
typeIs (res :: AffjaxResponse Foreign)
103+
(attempt $ AX.put mirror content) >>= assertRight >>= \res -> do
104+
typeIs (res :: AX.AffjaxResponse Foreign)
109105
assertEq ok200 res.status
110106
let mirroredReq = unsafeFromForeign res.response
111107
assertEq "PUT" mirroredReq.method
112108
assertEq content mirroredReq.body
113109

114110
A.log "Testing CORS, HTTPS"
115-
(attempt $ get "https://cors-test.appspot.com/test") >>= assertRight >>= \res -> do
116-
typeIs (res :: AffjaxResponse Foreign)
111+
(attempt $ AX.get "https://cors-test.appspot.com/test") >>= assertRight >>= \res -> do
112+
typeIs (res :: AX.AffjaxResponse Foreign)
117113
assertEq ok200 res.status
118114
-- assertEq (Just "test=test") (lookupHeader "Set-Cookie" res.headers)
119115

120116
A.log "Testing cancellation"
121-
canceler <- forkAff (post_ mirror "do it now")
117+
canceler <- forkAff (AX.post_ mirror "do it now")
122118
canceled <- canceler `cancel` error "Pull the cord!"
123119
assertMsg "Should have been canceled" canceled

0 commit comments

Comments
 (0)