package seo import ( "context" "testing" ) func TestSettingHTMLComponent(t *testing.T) { tests := []struct { name string setting Setting tags map[string]string want string }{ { name: "Render the seo html", setting: Setting{ Title: "title", Description: "description", Keywords: "keyword", OpenGraphTitle: "og title", OpenGraphDescription: "og description", OpenGraphURL: "http://dev.qor5.com/product/1", OpenGraphType: "", OpenGraphImageURL: "http://dev.qor5.com/product/1/og.jpg", }, tags: map[string]string{}, want: ` title `, }, { name: "Render the seo html using the tag data", setting: Setting{ Title: "title", Description: "description", Keywords: "keyword", OpenGraphTitle: "og title", OpenGraphDescription: "og description", OpenGraphURL: "http://dev.qor5.com/product/1", OpenGraphType: "", OpenGraphImageURL: "http://dev.qor5.com/product/1/og.jpg", }, tags: map[string]string{ "og:type": "product", "twiiter:image": "http://dev.qor5.com/product/1/twitter.jpg", }, want: ` title `, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got, _ := tt.setting.HTMLComponent(tt.tags).MarshalHTML(context.TODO()); !metaEqual(string(got), tt.want) { t.Errorf("Setting.HTMLComponent() = %v, want %v", string(got), tt.want) } }) } }