-
Notifications
You must be signed in to change notification settings - Fork 0
/
params_test.go
51 lines (43 loc) · 1.09 KB
/
params_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package rajaongkir_go
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"net/url"
"testing"
)
type ParamsTestSuite struct {
suite.Suite
}
func (suite *ParamsTestSuite) TestProvinceParamsSuccess() {
urlValues := urlValues(ProvinceParams{ID: "1"})
assert.Equal(suite.T(), url.Values{"id": {"1"}}, urlValues)
}
func (suite *ParamsTestSuite) TestCityParamsSuccess() {
urlValues := urlValues(CityParams{ID: "1", ProvinceID: "1"})
assert.Equal(suite.T(), url.Values{"id": {"1"}, "province": {"1"}}, urlValues)
}
func (suite *ParamsTestSuite) TestCostParamsSuccess() {
urlValues := urlValues(CostParams{
Origin: "1",
Destination: "1",
Weight: 1,
Courier: JNE,
})
assert.Equal(
suite.T(),
url.Values{
"origin": {"1"},
"destination": {"1"},
"weight": {"1"},
"courier": {"jne"},
},
urlValues,
)
}
func (suite *ParamsTestSuite) TestCourierParamsSuccess() {
result := CourierParams("JNE", "TIKI")
assert.Equal(suite.T(), "JNE:TIKI", result)
}
func TestParamsTestSuite(t *testing.T) {
suite.Run(t, new(ParamsTestSuite))
}