广告点击添加
This commit is contained in:
@@ -45,3 +45,30 @@ func TestBuildAppConfigVMFallsBackToLegacyBannerField(t *testing.T) {
|
||||
t.Fatalf("DetailBannerList = %#v, want detailbannerList fallback", vm.DetailBannerList)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildAppConfigVMParsesAdsClickID(t *testing.T) {
|
||||
vm := BuildAppConfigVM(&ConfigInfoResp{
|
||||
Advitise: AdvitiseData{
|
||||
NineGridList: []Advertisement{
|
||||
{ID: " 1138200002 ", Location: 2, Images: "https://cdn.example.com/a.gif"},
|
||||
{ID: "1138200003", Location: 2, AdvertiseCode: "code-x", Images: "https://cdn.example.com/b.gif"},
|
||||
{ID: "abc", Location: 2, Images: "https://cdn.example.com/c.gif"},
|
||||
{ID: "1138200004", Location: 0, Images: "https://cdn.example.com/d.gif"},
|
||||
},
|
||||
},
|
||||
})
|
||||
got := vm.NineGridList
|
||||
if len(got) != 4 {
|
||||
t.Fatalf("NineGridList = %#v", got)
|
||||
}
|
||||
if got[0].AdsID != 1138200002 || !got[0].CanReportClick() {
|
||||
t.Fatalf("item0 = %#v, want reportable id 1138200002", got[0])
|
||||
}
|
||||
// advertiseCode 覆盖展示 ID,但点击上报仍用上游原始 id
|
||||
if got[1].ID != "code-x" || got[1].AdsID != 1138200003 {
|
||||
t.Fatalf("item1 = %#v, want AdsID from raw id", got[1])
|
||||
}
|
||||
if got[2].CanReportClick() || got[3].CanReportClick() {
|
||||
t.Fatalf("invalid id/location must not report: %#v %#v", got[2], got[3])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user