forked from yyoshiki41/go-radiko
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea_test.go
More file actions
34 lines (28 loc) · 689 Bytes
/
area_test.go
File metadata and controls
34 lines (28 loc) · 689 Bytes
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
package radiko
import (
"strings"
"testing"
"golang.org/x/net/html"
)
func TestAreaID(t *testing.T) {
areaID, err := AreaID()
if err != nil {
t.Errorf("Failed to get area id: %s", err)
}
if !(strings.HasPrefix(areaID, "JP") || areaID == "OUT") {
t.Errorf("Invalid area id.\nAreaID: %s", areaID)
}
}
func TestProcessSpanNode(t *testing.T) {
const expected = "JP13"
s := `document.write('<span class="` + expected + `">TOKYO JAPAN</span>');`
doc, err := html.Parse(strings.NewReader(s))
if err != nil {
t.Errorf("Parse HTML: %s", err)
}
areaID := processSpanNode(doc)
if areaID != expected {
t.Errorf(
"Failed to process span node.\nAreaID: %s", areaID)
}
}