/**
 * Przyjmuje asercję, że getLineItemTotal działa zgodnie z oczekiwaniami.
 */
var testGetLineItemTotal = function () {
    var lineItem1 = {
        price: 50,
        quantity: 1
    };
 
    var lineItem2 = {
        price: 100,
        quantity: 2
    };
 
    var lineItemTotal = getLineItemTotal([lineItem1, lineItem2]);
    var expectedTotal = 250;
 
    if (lineItemTotal === expectedTotal) {
      successfulTestCount++;
    } else {
      unsuccessfulTestCount++;
      unsuccessfulTestSummaries.push(
          'testGetLineItemTotal: oczekiwane ' + expectedTotal + '; otrzymane ' + lineItemTotal
      );
    }
};

/**
 * Przyjmuje asercję, że getShippingTotal działa zgodnie z oczekiwaniami.
 */
var testGetShippingTotal = function () {
    var lineItem1 = {
        quantity: 1,
        shippingPrice: 10
    };
 
    var lineItem2 = {
        quantity: 2,
        shippingPrice: 20
    };
 
    var shippingTotal = getShippingTotal([lineItem1, lineItem2]);
    var expectedTotal = 250;
 
    if (shippingTotal === expectedTotal) {
      successfulTestCount++;
    } else {
      unsuccessfulTestCount++;
      unsuccessfulTestSummaries.push(
          'testGetShippingTotal: oczekiwane ' + expectedTotal + '; otrzymane ' + shippingTotal
      );
    }
};

/**
 * Upewnia się, że GetDiscountTotal działa zgodnie z oczekiwaniami,
 * gdy zastosowany zostanie prawidłowy kod rabatu.
 */
var testGetDiscountTotalWithValidDiscountCode = function () {
    var discountTotal = getDiscountTotal(100, '20PERCENT');
    var expectedTotal = 20;
 
    if (discountTotal === expectedTotal) {
      successfulTestCount++;
    } else {
      unsuccessfulTestCount++;
      unsuccessfulTestSummaries.push(
          'testGetDiscountTotalWithValidDiscountCode: oczekiwane ' + expectedTotal + '; otrzymane ' + discountTotal
      );
    }
};

/**
 * Upewnia się, że GetDiscountTotal działa zgodnie z oczekiwaniami,
 * gdy zastosowany zostanie nieprawidłowy kod rabatu.
 */
var testGetDiscountTotalWithInvalidDiscountCode = function () {
    var discountTotal = get_discount_total(100, '90PERCENT');
    var expectedTotal = 0;
 
    if (discountTotal === expectedTotal) {
      successfulTestCount++;
    } else {
      unsuccessfulTestCount++;
      unsuccessfulTestSummaries.push(
          'testGetDiscountTotalWithInvalidDiscountCode: oczekiwane ' + expectedTotal + '; otrzymane ' + discountTotal
      );
    }
};

/**
 * Upewnia się, że GetTaxTotal działa zgodnie z oczekiwaniami, gdy klient mieszka w Kalifornii.
 */
var testGetTaxTotalForCaliforniaResident = function () {
    var customer = {
      shiptoState: 'CA'
    };

    var taxTotal = getTaxTotal(100, customer);
    var expectedTotal = 8;
 
    if (taxTotal === expectedTotal) {
      successfulTestCount++;
    } else {
      unsuccessfulTestCount++;
      unsuccessfulTestSummaries.push(
          'testGetTaxTotalForCaliforniaResident: oczekiwane ' + expectedTotal + '; otrzymane ' + taxTotal
      );
    }
};

/**
 * Upewnia się, że GetTaxTotal działa zgodnie z oczekiwaniami, gdy klient nie mieszka w Kalifornii.
 */
var testGetTaxTotalForNonCaliforniaResident = function () {
    var customer = {
        shiptoState: 'MA'
    };
 
    var taxTotal = getTaxTotal(100, customer);
    var expectedTotal = 0;
 
    if (taxTotal === expectedTotal) {
      successfulTestCount++;
    } else {
      unsuccessfulTestCount++;
      unsuccessfulTestSummaries.push(
          'testGetTaxTotalForNonCaliforniaResident: oczekiwane ' + expectedTotal + '; otrzymane ' + taxTotal
      );
    }
};
