-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.spec.ts
111 lines (106 loc) · 6.25 KB
/
status.spec.ts
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import testMatrix from "jest-test-matrix";
import {
PaymentStatus,
ProductAvailability,
Props,
ShippingStatus,
checkOrderStatus,
} from "./status";
const rejected = "🔴";
const approved = "🟢";
const pending = "🟡";
const testCheck = (props: Props) => {
const orderStatus = checkOrderStatus(props);
if (orderStatus === "Rejected") {
return rejected;
}
if (orderStatus === "Approved") {
return approved;
}
if (orderStatus === "Pending") {
return pending;
}
};
test("calculates order status", () => {
expect(
testMatrix(testCheck, {
paymentStatus: [
PaymentStatus.Failed,
PaymentStatus.Paid,
PaymentStatus.Pending,
],
shippingStatus: [
ShippingStatus.Shipped,
ShippingStatus.Processing,
ShippingStatus.NotAvailable,
],
productAvailability: [
ProductAvailability.InStock,
ProductAvailability.LowStock,
ProductAvailability.OutOfStock,
],
isPriorityCustomer: [true, false],
}),
).toMatchInlineSnapshot(`
.--------------------------------------------------------------------------------.
| testCheck |
|--------------------------------------------------------------------------------|
| isPriorityCustomer | paymentStatus | shippingStatus | productAvailability | |
|--------------------|---------------|----------------|---------------------|----|
| true | FAILED | SHIPPED | IN_STOCK | 🔴 |
| | | | LOW_STOCK | 🔴 |
| | | | OUT_OF_STOCK | 🔴 |
| | | PROCESSING | IN_STOCK | 🔴 |
| | | | LOW_STOCK | 🔴 |
| | | | OUT_OF_STOCK | 🔴 |
| | | NOT_AVAILABLE | IN_STOCK | 🔴 |
| | | | LOW_STOCK | 🔴 |
| | | | OUT_OF_STOCK | 🔴 |
| | PAID | SHIPPED | IN_STOCK | 🟢 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | PROCESSING | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | NOT_AVAILABLE | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | PENDING | SHIPPED | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | PROCESSING | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | NOT_AVAILABLE | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| false | FAILED | SHIPPED | IN_STOCK | 🔴 |
| | | | LOW_STOCK | 🔴 |
| | | | OUT_OF_STOCK | 🔴 |
| | | PROCESSING | IN_STOCK | 🔴 |
| | | | LOW_STOCK | 🔴 |
| | | | OUT_OF_STOCK | 🔴 |
| | | NOT_AVAILABLE | IN_STOCK | 🔴 |
| | | | LOW_STOCK | 🔴 |
| | | | OUT_OF_STOCK | 🔴 |
| | PAID | SHIPPED | IN_STOCK | 🟢 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | PROCESSING | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | NOT_AVAILABLE | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | PENDING | SHIPPED | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | PROCESSING | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
| | | NOT_AVAILABLE | IN_STOCK | 🟡 |
| | | | LOW_STOCK | 🟡 |
| | | | OUT_OF_STOCK | 🔴 |
'--------------------------------------------------------------------------------'
`);
});