-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit_page_test.go
39 lines (33 loc) · 965 Bytes
/
edit_page_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
package telegraph_test
import (
"testing"
"github.com/TechMinerApps/telegraph"
"github.com/stretchr/testify/assert"
)
func Test_client_EditPage(t *testing.T) {
t.Run("Invalid", func(t *testing.T) {
c := telegraph.NewClient()
content, err := c.ContentFormat("<p>Hello, world!</p>")
assert.NoError(t, err)
_, err = c.EditPage(telegraph.Page{
Title: "Sample Page",
AuthorName: "Anonymous",
Content: content,
}, true)
assert.Error(t, err)
})
t.Run("Valid", func(t *testing.T) {
c, err := telegraph.NewClientWithToken("b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb")
assert.NoError(t, err)
content, err := c.ContentFormat("<p>Hello, world!</p>")
assert.NoError(t, err)
page, err := c.EditPage(telegraph.Page{
Path: "Sample-Page-12-15",
Title: "Sample Page",
AuthorName: "Anonymous",
Content: content,
}, true)
assert.NoError(t, err)
assert.NotEmpty(t, page.Content)
})
}