68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
package user
|
|
|
|
import "testing"
|
|
|
|
func TestShouldShowBindEmailTrialPrompt(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
hasBoundEmail bool
|
|
hasPurchased bool
|
|
hasTrial bool
|
|
want bool
|
|
}{
|
|
{
|
|
name: "new user should see prompt",
|
|
want: true,
|
|
},
|
|
{
|
|
name: "bound email should hide prompt",
|
|
hasBoundEmail: true,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "paid purchase should hide prompt",
|
|
hasPurchased: true,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "trial claimed should hide prompt",
|
|
hasTrial: true,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "bound email and purchase should hide prompt",
|
|
hasBoundEmail: true,
|
|
hasPurchased: true,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "bound email and trial should hide prompt",
|
|
hasBoundEmail: true,
|
|
hasTrial: true,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "purchase and trial should hide prompt",
|
|
hasPurchased: true,
|
|
hasTrial: true,
|
|
want: false,
|
|
},
|
|
{
|
|
name: "all blockers should hide prompt",
|
|
hasBoundEmail: true,
|
|
hasPurchased: true,
|
|
hasTrial: true,
|
|
want: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := shouldShowBindEmailTrialPrompt(tt.hasBoundEmail, tt.hasPurchased, tt.hasTrial)
|
|
if got != tt.want {
|
|
t.Fatalf("shouldShowBindEmailTrialPrompt(%v, %v, %v) = %v, want %v", tt.hasBoundEmail, tt.hasPurchased, tt.hasTrial, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|