-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathurl_scheme_test.go
51 lines (45 loc) · 1.21 KB
/
url_scheme_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 mixin
import (
"testing"
"github.com/shopspring/decimal"
"github.com/stretchr/testify/assert"
)
func TestUrlScheme_Transfer(t *testing.T) {
userID := newUUID()
url := URL.Transfer(userID)
assert.Equal(t, "mixin://transfer/"+userID, url)
}
func TestUrlScheme_SafePay(t *testing.T) {
input := &TransferInput{
AssetID: newUUID(),
OpponentID: newUUID(),
Amount: decimal.NewFromInt(100),
TraceID: newUUID(),
Memo: "test",
}
url := URL.SafePay(input)
t.Log(url)
}
func TestUrlScheme_Apps(t *testing.T) {
t.Run("default action", func(t *testing.T) {
appID := newUUID()
action := ""
url := URL.Apps(appID, action, nil)
assert.Equal(t, "mixin://apps/"+appID+"?action=open", url)
})
t.Run("specify action", func(t *testing.T) {
appID := newUUID()
action := "close"
url := URL.Apps(appID, action, nil)
assert.Equal(t, "mixin://apps/"+appID+"?action="+action, url)
})
t.Run("specify params", func(t *testing.T) {
appID := newUUID()
action := ""
params := map[string]string{"k1": "v1", "k2": "v2"}
url := URL.Apps(appID, action, params)
assert.Contains(t, url, "mixin://apps/"+appID+"?action=open")
assert.Contains(t, url, "k1=v1")
assert.Contains(t, url, "k2=v2")
})
}