Skip to content

Commit

Permalink
test(api): local scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
sundowndev committed Mar 27, 2020
1 parent 2fc0487 commit ae5efaa
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ func TestApi(t *testing.T) {
})
})

t.Run("localScan - /api/numbers/:number/scan/local", func(t *testing.T) {
t.Run("valid number", func(t *testing.T) {
res, err := performRequest(r, "GET", "/api/numbers/3312345253/scan/local")

body, _ := ioutil.ReadAll(res.Body)

assert.Equal(err, nil, "should be equal")
assert.Equal(res.Result().StatusCode, 200, "should be equal")
assert.Equal(string(body), `{"success":true,"error":"","result":{"rawLocal":"12345253","local":"12345253","E164":"+3312345253","international":"3312345253","countryCode":33,"country":"FR","carrier":""}}`, "should be equal")
})

t.Run("invalid number", func(t *testing.T) {
res, err := performRequest(r, "GET", "/api/numbers/9999999999/scan/local")

body, _ := ioutil.ReadAll(res.Body)

assert.Equal(err, nil, "should be equal")
assert.Equal(res.Result().StatusCode, 500, "should be equal")
assert.Equal(string(body), `{"success":false,"error":"invalid country code"}`, "should be equal")
})
})

// t.Run("healthHandler - /api/", func(t *testing.T) {
// res, err := performRequest(r, "GET", "/api")

Expand Down

0 comments on commit ae5efaa

Please sign in to comment.