UNPKG

beerbay-math

Version:

58 lines (49 loc) 2.42 kB
"use strict"; var _total = require("./total"); var _cart = require("./mock/cart"); var _countries = require("./mock/countries"); var _coupon = require("./mock/coupon"); var _cart2 = require("./cart"); var _coupon2 = require("./coupon"); var _shipping = require("./shipping"); var SELECTED_COUNTRY = _countries.MOCK_SHIPPING_COUNTRIES[0]; //Spain describe("Test for Totals", function () { test("getFullPrice for cart", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY)).toBe(78.15); }); }); describe("Test for Totals", function () { test("getFullPrice after applying free shipping coupon", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.FREE_SHIPPING_SPAIN_COUPON)).toBe(78.15 - 4.95); }); }); describe("Test for Totals", function () { test("getFullPrice after applying free flat coupon", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.USD_10_COUPON)).toBe(68.15); }); }); describe("Test for Totals", function () { test("getFullPrice after applying percentage coupon", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.PERCENTAGE_20_COUPON)).toBe(63.51); }); }); describe("Test for Totals", function () { test("display correct value after applying coupon", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.PERCENTAGE_20_COUPON)).toBe(Number(((0, _cart2.getCartPrice)(_cart.MOCK_CART) + (0, _shipping.getShippingFinal)(_cart.MOCK_CART, SELECTED_COUNTRY) - (0, _coupon2.getCouponValue)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.PERCENTAGE_20_COUPON)).toFixed(2))); }); }); describe("Test for Totals", function () { test("display correct price when coupon is not active", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.INACTIVE_COUPON)).toBe(78.15); }); }); describe("Test for Totals", function () { test("display correct price when coupon is null", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, null)).toBe(78.15); }); }); describe("Test for Totals", function () { test("display correct price when coupon is set, but the user is null", function () { expect((0, _total.getFullPrice)(_cart.MOCK_CART, SELECTED_COUNTRY, _coupon.PERCENTAGE_20_COUPON, null)).toBe(63.51); }); });