Parses multiple values for a property
This commit is contained in:
		
							parent
							
								
									d6e293d40a
								
							
						
					
					
						commit
						a650a2c9e9
					
				@ -251,7 +251,7 @@ func TestReadTwoValues(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	item := ReadOneItem(html, t)
 | 
			
		||||
	if len(item.properties["flavor"]) != 2 {
 | 
			
		||||
		t.Errorf("Expecting 2 items but got %d",len(item.properties["flavor"]) )
 | 
			
		||||
		t.Errorf("Expecting 2 values but got %d",len(item.properties["flavor"]) )
 | 
			
		||||
	}
 | 
			
		||||
	if item.properties["flavor"][0].(string) != "Lemon sorbet" {
 | 
			
		||||
		t.Errorf("Property value 'Lemon sorbet' not found")
 | 
			
		||||
@ -262,3 +262,26 @@ func TestReadTwoValues(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestReadTwoPropertiesOneValue(t *testing.T) {
 | 
			
		||||
	html := `
 | 
			
		||||
	<div itemscope>
 | 
			
		||||
	 <span itemprop="favorite-color favorite-fruit">orange</span>
 | 
			
		||||
	</div>`
 | 
			
		||||
 | 
			
		||||
	item := ReadOneItem(html, t)
 | 
			
		||||
	if len(item.properties["favorite-color"]) != 2 {
 | 
			
		||||
		t.Errorf("Expecting 1 value but got %d",len(item.properties["favorite-color"]) )
 | 
			
		||||
	}
 | 
			
		||||
	if len(item.properties["favorite-fruit"]) != 2 {
 | 
			
		||||
		t.Errorf("Expecting 1 value but got %d",len(item.properties["favorite-fruit"]) )
 | 
			
		||||
	}
 | 
			
		||||
	if item.properties["favorite-color"][0].(string) != "orange" {
 | 
			
		||||
		t.Errorf("Property value 'orange' not found for 'favorite-color'")
 | 
			
		||||
	}
 | 
			
		||||
	if item.properties["favorite-fruit"][0].(string) != "orange" {
 | 
			
		||||
		t.Errorf("Property value 'orange' not found for 'favorite-fruit'")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user