Use switch-case to get coupons
This commit is contained in:
parent
cd463d0a92
commit
60b5b183da
|
@ -26,29 +26,29 @@ const couponsTable = [
|
||||||
['fixed product', { text: '$5.00' }, { text: '$4.99' }]
|
['fixed product', { text: '$5.00' }, { text: '$4.99' }]
|
||||||
];
|
];
|
||||||
|
|
||||||
let coupons;
|
let couponFixedCart;
|
||||||
|
let couponPercentage;
|
||||||
|
let couponFixedProduct;
|
||||||
|
|
||||||
const getCoupon = (couponType) => {
|
const getCoupon = (couponType) => {
|
||||||
const coupon = coupons.find((pair) => pair.includes(couponType))[1];
|
switch (couponType) {
|
||||||
return coupon;
|
case 'fixed cart':
|
||||||
|
return couponFixedCart;
|
||||||
|
case 'percentage':
|
||||||
|
return couponPercentage;
|
||||||
|
case 'fixed product':
|
||||||
|
return couponFixedProduct;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const runCartApplyCouponsTest = () => {
|
const runCartApplyCouponsTest = () => {
|
||||||
describe('Cart applying coupons', () => {
|
describe('Cart applying coupons', () => {
|
||||||
let couponFixedCart;
|
|
||||||
let couponPercentage;
|
|
||||||
let couponFixedProduct;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await createSimpleProduct();
|
await createSimpleProduct();
|
||||||
couponFixedCart = await createCoupon();
|
couponFixedCart = await createCoupon();
|
||||||
couponPercentage = await createCoupon('50', 'Percentage discount');
|
couponPercentage = await createCoupon('50', 'Percentage discount');
|
||||||
couponFixedProduct = await createCoupon('5', 'Fixed product discount');
|
couponFixedProduct = await createCoupon('5', 'Fixed product discount');
|
||||||
coupons = [
|
|
||||||
['fixed cart', couponFixedCart],
|
|
||||||
['percentage', couponPercentage],
|
|
||||||
['fixed product', couponFixedProduct]
|
|
||||||
];
|
|
||||||
await shopper.emptyCart();
|
await shopper.emptyCart();
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await shopper.addToCartFromShopPage('Simple product');
|
await shopper.addToCartFromShopPage('Simple product');
|
||||||
|
|
|
@ -27,29 +27,28 @@ const couponsTable = [
|
||||||
['fixed product', { text: '$5.00' }, { text: '$4.99' }]
|
['fixed product', { text: '$5.00' }, { text: '$4.99' }]
|
||||||
];
|
];
|
||||||
|
|
||||||
let coupons;
|
let couponFixedCart;
|
||||||
|
let couponPercentage;
|
||||||
|
let couponFixedProduct;
|
||||||
|
|
||||||
const getCoupon = (couponType) => {
|
const getCoupon = (couponType) => {
|
||||||
const coupon = coupons.find((pair) => pair.includes(couponType))[1];
|
switch (couponType) {
|
||||||
return coupon;
|
case 'fixed cart':
|
||||||
|
return couponFixedCart;
|
||||||
|
case 'percentage':
|
||||||
|
return couponPercentage;
|
||||||
|
case 'fixed product':
|
||||||
|
return couponFixedProduct;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const runCheckoutApplyCouponsTest = () => {
|
const runCheckoutApplyCouponsTest = () => {
|
||||||
describe('Checkout coupons', () => {
|
describe('Checkout coupons', () => {
|
||||||
let couponFixedCart;
|
|
||||||
let couponPercentage;
|
|
||||||
let couponFixedProduct;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await createSimpleProduct();
|
await createSimpleProduct();
|
||||||
couponFixedCart = await createCoupon();
|
couponFixedCart = await createCoupon();
|
||||||
couponPercentage = await createCoupon('50', 'Percentage discount');
|
couponPercentage = await createCoupon('50', 'Percentage discount');
|
||||||
couponFixedProduct = await createCoupon('5', 'Fixed product discount');
|
couponFixedProduct = await createCoupon('5', 'Fixed product discount');
|
||||||
coupons = [
|
|
||||||
['fixed cart', couponFixedCart],
|
|
||||||
['percentage', couponPercentage],
|
|
||||||
['fixed product', couponFixedProduct]
|
|
||||||
];
|
|
||||||
await shopper.emptyCart();
|
await shopper.emptyCart();
|
||||||
await shopper.goToShop();
|
await shopper.goToShop();
|
||||||
await waitForSelectorWithoutThrow( '.add_to_cart_button' );
|
await waitForSelectorWithoutThrow( '.add_to_cart_button' );
|
||||||
|
|
Loading…
Reference in New Issue