-
Notifications
You must be signed in to change notification settings - Fork 577
/
Copy pathconfig.test.js
96 lines (76 loc) · 2.85 KB
/
config.test.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* @flow */
import { describe, expect } from "vitest";
import { BUTTON_FLOW } from "../../constants";
import { getVenmoConfig } from "./config";
describe("Venmo eligibility", () => {
const baseEligibilityProps = {
fundingSource: undefined,
components: ["buttons"],
fundingEligibility: {},
experiment: {
venmoWebEnabled: true,
venmoEnableWebOnNonNativeBrowser: true,
},
wallet: expect.any,
flow: BUTTON_FLOW.PURCHASE,
};
const venmoConfig = getVenmoConfig();
test("should not be eligible if a shipping callback is passed and displayOnly=['vaultable']", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
shippingChange: true,
displayOnly: ["vaultable"],
});
expect(isVenmoEligible).toEqual(false);
});
test("should be eligible if a shipping callback is present but not displayOnly", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
shippingChange: true,
});
expect(isVenmoEligible).toEqual(true);
});
test("should be eligible if displayOnly=['vaultable'] but no shipping callback is present", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
displayOnly: ["vaultable"],
});
expect(isVenmoEligible).toEqual(true);
});
test("should be eligible if neither a shipping callback nor displayOnly is present", () => {
const isVenmoEligible = venmoConfig.eligible?.(baseEligibilityProps);
expect(isVenmoEligible).toEqual(true);
});
test("should not be eligible if flow is VAULT_WITHOUT_PURCHASE and venmoVaultWithoutPurchase is false", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
flow: BUTTON_FLOW.VAULT_WITHOUT_PURCHASE,
});
expect(isVenmoEligible).toEqual(false);
});
test("should be eligible if flow is VAULT_WITHOUT_PURCHASE and venmoVaultWithoutPurchase is true", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
flow: BUTTON_FLOW.VAULT_WITHOUT_PURCHASE,
experiment: {
venmoVaultWithoutPurchase: true,
},
});
expect(isVenmoEligible).toEqual(true);
});
test("should not be eligible if a shipping callback is passed & experiment does not include venmoWebEnabled or venmoEnableWebOnNonNativeBrowser", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
experiment: {},
shippingChange: true,
});
expect(isVenmoEligible).toEqual(false);
});
test("should be eligible if shipping callback exists & experiment includes venmoWebEnabled or venmoEnableWebOnNonNativeBrowser", () => {
const isVenmoEligible = venmoConfig.eligible?.({
...baseEligibilityProps,
shippingChange: true,
});
expect(isVenmoEligible).toEqual(true);
});
});