From a4244ac31dfd6e679cdabd1d0d2480c210bb2905 Mon Sep 17 00:00:00 2001 From: Ian Davis Date: Sun, 10 Jun 2012 15:27:23 +0100 Subject: [PATCH] Added multi-valued itemrefs --- microdata_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/microdata_test.go b/microdata_test.go index 380e6b1..4c85916 100644 --- a/microdata_test.go +++ b/microdata_test.go @@ -446,3 +446,29 @@ func TestParseMultiValuedItemRef(t *testing.T) { t.Errorf("Property value '26' not found for 'age'") } } + + +func TestParseEmbeddedItem(t *testing.T) { + html := `
+

Name: Amanda

+

Band: Jazz Band (12 players)

+
` + + data := ParseData(html, t) + + if len(data.items) != 1 { + t.Errorf("Expecting 1 item but got %d", len(data.items)) + } + + + if data.items[0].properties["name"][0].(string) != "Amanda" { + t.Errorf("Property value 'Amanda' not found for 'name'") + } + + subitem := data.items[0].properties["band"][0].(Item) + + if subitem.properties["name"][0].(string) != "Jazz Band" { + t.Errorf("Property value 'Jazz Band' not found for 'name'") + } +} +