forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynctype_test.go
52 lines (46 loc) · 1.45 KB
/
synctype_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package usersync
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSyncTypeFilter(t *testing.T) {
bidder := "foo"
bidderFilterAllowed := NewUniformBidderFilter(BidderFilterModeInclude)
bidderFilterNotAllowed := NewUniformBidderFilter(BidderFilterModeExclude)
testCases := []struct {
description string
givenIFrameFilter BidderFilter
givenRedirectFilter BidderFilter
expectedSyncTypes []SyncType
}{
{
description: "None",
givenIFrameFilter: bidderFilterNotAllowed,
givenRedirectFilter: bidderFilterNotAllowed,
expectedSyncTypes: []SyncType{},
},
{
description: "IFrame Only",
givenIFrameFilter: bidderFilterAllowed,
givenRedirectFilter: bidderFilterNotAllowed,
expectedSyncTypes: []SyncType{SyncTypeIFrame},
},
{
description: "Redirect Only",
givenIFrameFilter: bidderFilterNotAllowed,
givenRedirectFilter: bidderFilterAllowed,
expectedSyncTypes: []SyncType{SyncTypeRedirect},
},
{
description: "All",
givenIFrameFilter: bidderFilterAllowed,
givenRedirectFilter: bidderFilterAllowed,
expectedSyncTypes: []SyncType{SyncTypeIFrame, SyncTypeRedirect},
},
}
for _, test := range testCases {
syncTypeFilter := SyncTypeFilter{IFrame: test.givenIFrameFilter, Redirect: test.givenRedirectFilter}
syncTypes := syncTypeFilter.ForBidder(bidder)
assert.ElementsMatch(t, test.expectedSyncTypes, syncTypes, test.description)
}
}