package flashscore
import (
"bytes"
"fmt"
"os"
"strings"
"github.com/PuerkitoBio/goquery"
// xhtml "golang.org/x/net/html"
//"strings"
"encoding/json"
"testing"
)
/*
func TestParseFootballZoneAndChamp(t *testing.T) {
var src = []byte(`ENGLAND - SERIA A - DIVISION 1: Premier League - Round 30
`)
doc, err := goquery.NewDocumentFromReader(bytes.NewBuffer(buf))
if err != nil {
t.Fatal(err)
}
// First -
f := doc.Find("div.teamHeader__name").First() //.Children()
txt := f.Text()
txt = strings.TrimSpace(txt)
champID := "/football/germany/bundesliga"
parts := strings.Split(champID, "/")
zoneID := strings.Join(parts[:3], "/")
fmt.Printf("%q\n\n%q\n\n", txt, zoneID)
//f := doc.Find("h2.tournament").First()
}
func TestParseEnvironmentJsVarOnMatchPageInJsVar(t *testing.T) {
// flashscore format
buf, err := os.ReadFile("for_parse/environmentJsVarOnMatchPage.html")
if err != nil {
t.Fatal(err)
}
doc, err := goquery.NewDocumentFromReader(bytes.NewBuffer(buf))
if err != nil {
t.Fatal(err)
}
home, away, err := parseTeamsOnMatchPageInJsVar(doc)
if err != nil {
t.Fatal(err)
}
buf, _ = json.MarshalIndent(home, "", " ")
fmt.Printf("%s\n\n", buf)
buf, _ = json.MarshalIndent(away, "", " ")
fmt.Printf("%s\n\n", buf)
}