import * as servicePackageHelper from '@/helpers/service-package-helper';
import partTypeStrings from '@/constants/part-type-strings.js';
import damageLocationsSelected from '@/constants/damage-locations-selected.js';
import packageNames from '@/constants/package-names.js';

const recalLineItem = {
    partNumber: 'RECAL STATIC',
    Description: 'Recalibration',
    partType: 'recalibration',
    Quantity: '1',
    price: 150.0
};

const driverFrontWiperLineItem = {
    partNumber: 'SBB16',
    description: 'SAFELITE BEAM BLADE 16',
    partType: 'FRONT WIPER',
    price: 32.64
};

const passengerFrontWiperLineItem = {
    partNumber: 'SBB26',
    description: 'SAFELITE BEAM BLADE 26',
    partType: 'FRONT WIPER',
    price: 53.04
};

const rearWiperLineItem = {
    partNumber: 'SBBR12A',
    description: 'SAFELITE REAR BLADE 12A',
    partType: 'REAR WIPER',
    price: 24.48
};

const rainDefenseLineItem = {
    partNumber: 'RAIN REPEL',
    description: null,
    partType: 'RAIN REPEL',
    price: 35.5
};

const frontWindshieldGlass = {
    glassLocation: 'Windshield'
};

const rearWindshieldGlass = {
    glassLocation: 'Rear'
};

const sideGlass = {
    glassLocation: 'Driver'
};

describe('service-package-helper.js', () => {
    describe('findLineItemsWithPartType', () => {
        it('Returns an item of the same type when present', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];
            const partType = partTypeStrings.RAIN_DEFENSE;

            // Act
            const result = servicePackageHelper.findLineItemsWithPartType(partType, lineItems);

            // Assert
            expect(result.length).toBe(1);
            expect(result[0].partType).toEqual(partType);
        });

        it('Returns an empty array when no matching items are present', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                passengerFrontWiperLineItem,
                driverFrontWiperLineItem
            ];
            const partType = partTypeStrings.RAIN_DEFENSE;

            // Act
            const result = servicePackageHelper.findLineItemsWithPartType(partType, lineItems);

            // Assert
            expect(result.length).toBe(0);
        });

        it('Returns all matching items when multiple are present', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];
            const partType = partTypeStrings.FRONT_WIPER;

            // Act
            const result = servicePackageHelper.findLineItemsWithPartType(partType, lineItems);

            // Assert
            expect(result.length).toBe(2);
            expect(result[0].partType).toEqual(partType);
            expect(result[1].partType).toEqual(partType);
            expect(result[0].partNumber).not.toEqual(result[1].partNumber);
        });

        it('Is not case sensitive', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];
            const partType = 'rAin rEpeL';

            // Act
            const result = servicePackageHelper.findLineItemsWithPartType(partType, lineItems);

            // Assert
            expect(result.length).toBe(1);
            expect(result[0].partType).toEqual(partTypeStrings.RAIN_DEFENSE);
        });
    });

    describe('containsLineItemWithPartType', () => {
        it('Returns true when type is present', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];
            const partType = partTypeStrings.RAIN_DEFENSE;

            // Act
            const result = servicePackageHelper.containsLineItemWithPartType(partType, lineItems);

            // Assert
            expect(result).toBe(true);
        });

        it('Returns true when type is present multiple times', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];
            const partType = partTypeStrings.FRONT_WIPER;

            // Act
            const result = servicePackageHelper.containsLineItemWithPartType(partType, lineItems);

            // Assert
            expect(result).toBe(true);
        });

        it('Returns false when type is not present', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem
            ];
            const partType = partTypeStrings.RAIN_DEFENSE;

            // Act
            const result = servicePackageHelper.containsLineItemWithPartType(partType, lineItems);

            // Assert
            expect(result).toBe(false);
        });

        it('Returns false with empty array', () => {
            // Arrange
            const lineItems = [];
            const partType = partTypeStrings.RAIN_DEFENSE;

            // Act
            const result = servicePackageHelper.containsLineItemWithPartType(partType, lineItems);

            // Assert
            expect(result).toBe(false);
        });
    });

    describe('getVapsLineItems', () => {
        it('Returns line items matching given types', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];

            const vapTypes = [partTypeStrings.RAIN_DEFENSE];

            // Act
            const result = servicePackageHelper.getVapsLineItems(lineItems, vapTypes);

            // Assert
            expect(result.length).toBe(1);
            expect(result[0].partType).toEqual(partTypeStrings.RAIN_DEFENSE);
        });

        it('Returns all matching line items, when multiple match a single type', () => {
            // Arrange
            const lineItems = [
                recalLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];

            const vapTypes = [partTypeStrings.FRONT_WIPER];

            // Act
            const result = servicePackageHelper.getVapsLineItems(lineItems, vapTypes);

            // Assert
            expect(result.length).toBe(2);
            expect(result[0].partType).toEqual(partTypeStrings.FRONT_WIPER);
            expect(result[1].partType).toEqual(partTypeStrings.FRONT_WIPER);
            expect(result[0].partNumber).not.toEqual(result[1].partNumber);
        });

        it('Returns only line items in the given set', () => {
            // Arrange
            const lineItems = [recalLineItem, passengerFrontWiperLineItem, rainDefenseLineItem];

            const vapTypes = [partTypeStrings.FRONT_WIPER];

            // Act
            const result = servicePackageHelper.getVapsLineItems(lineItems, vapTypes);

            // Assert
            expect(result.length).toBe(1);
            expect(result[0].partType).toEqual(partTypeStrings.FRONT_WIPER);
            expect(result[0].partNumber).toEqual(passengerFrontWiperLineItem.partNumber);
        });

        it('Returns all matching items when multiple vap types are requested', () => {
            // Arrange
            const lineItems = [recalLineItem, passengerFrontWiperLineItem, rainDefenseLineItem];

            const vapTypes = [partTypeStrings.FRONT_WIPER, partTypeStrings.RAIN_DEFENSE];

            // Act
            const result = servicePackageHelper.getVapsLineItems(lineItems, vapTypes);

            // Assert
            expect(result.length).toBe(2);
            expect(result[0].partType).not.toEqual(result[1].partType);
        });
    });

    describe('containsGlassPieceWithLocation', () => {
        it('Returns true when location is present', () => {
            // Arrange
            const locations = [frontWindshieldGlass, sideGlass];

            const locationName = damageLocationsSelected.WINDSHIELD;

            // Act
            const result = servicePackageHelper.containsGlassPieceWithLocation(
                locationName,
                locations
            );

            // Assert
            expect(result).toBe(true);
        });

        it('Returns true when location is present multiple times', () => {
            // Arrange
            const locations = [frontWindshieldGlass, frontWindshieldGlass, sideGlass];

            const locationName = damageLocationsSelected.WINDSHIELD;

            // Act
            const result = servicePackageHelper.containsGlassPieceWithLocation(
                locationName,
                locations
            );

            // Assert
            expect(result).toBe(true);
        });

        it('Returns false when location is not present', () => {
            // Arrange
            const locations = [frontWindshieldGlass, sideGlass];

            const locationName = damageLocationsSelected.REAR;

            // Act
            const result = servicePackageHelper.containsGlassPieceWithLocation(
                locationName,
                locations
            );

            // Assert
            expect(result).toBe(false);
        });

        it('Returns false with empty array', () => {
            // Arrange
            const locations = [];

            const locationName = damageLocationsSelected.WINDSHIELD;

            // Act
            const result = servicePackageHelper.containsGlassPieceWithLocation(
                locationName,
                locations
            );

            // Assert
            expect(result).toBe(false);
        });

        it('Is not case sensitive', () => {
            // Arrange
            const locations = [frontWindshieldGlass, sideGlass];

            const locationName = 'windShieLd';

            // Act
            const result = servicePackageHelper.containsGlassPieceWithLocation(
                locationName,
                locations
            );

            // Assert
            expect(result).toBe(true);
        });
    });

    describe('getAvailablePackages', () => {
        it('Returns two packages when there is not a viable tier-two option.', () => {
            // Arrange
            const damageLocations = [sideGlass];

            const availableLineItems = [rainDefenseLineItem];

            // Act
            const results = servicePackageHelper.getAvailablePackages(
                damageLocations,
                availableLineItems,
                false
            );

            // Assert
            expect(results.length).toBe(2);
            expect(results[0].packageName).toEqual(packageNames.TIER_ONE);
            expect(results[1].packageName).toEqual(packageNames.TIER_THREE);
        });

        it('Returns three packages when wipers are available in tier two', () => {
            // Arrange
            const damageLocations = [rearWindshieldGlass];

            const availableLineItems = [
                driverFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];

            // Act
            const results = servicePackageHelper.getAvailablePackages(
                damageLocations,
                availableLineItems,
                true
            );

            // Assert
            expect(results.length).toBe(3);
            expect(results[0].packageName).toEqual(packageNames.TIER_ONE);
            expect(results[1].packageName).toEqual(packageNames.TIER_TWO);
            expect(results[2].packageName).toEqual(packageNames.TIER_THREE);
        });
    });

    // TODO write tests
    describe('getPackageContents', () => {
        describe('Match figma cases', () => {
            test.todo('Implement specific cases.');
        });
    });

    describe('shouldFrontWipersBeAvailable', () => {
        it('Should be available in tier 2 and 3 if windshield damage and available', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [driverFrontWiperLineItem, passengerFrontWiperLineItem];
            const isRepair = false;

            // Act
            const resultTwo = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_TWO
            );
            const resultThree = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_THREE
            );

            // Assert
            expect(resultTwo).toBe(true);
            expect(resultThree).toBe(true);
        });

        it('Should be available in tier 2 and 3 if repair and available', () => {
            // Arrange
            const damageLocations = [];
            const availableLineItems = [driverFrontWiperLineItem, passengerFrontWiperLineItem];
            const isRepair = true;

            // Act
            const resultTwo = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_TWO
            );
            const resultThree = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_THREE
            );

            // Assert
            expect(resultTwo).toBe(true);
            expect(resultThree).toBe(true);
        });

        it('Should not be available in tier 2 if not windshield damage or repair', () => {
            // Arrange
            const damageLocations = [];
            const availableLineItems = [driverFrontWiperLineItem, passengerFrontWiperLineItem];
            const isRepair = false;

            // Act
            const result = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_TWO
            );

            // Assert
            expect(result).toBe(false);
        });

        it('Should be available in tier 3 even if not windshield repair or replace', () => {
            // Arrange
            const damageLocations = [];
            const availableLineItems = [driverFrontWiperLineItem, passengerFrontWiperLineItem];
            const isRepair = false;

            // Act
            const result = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_THREE
            );

            // Assert
            expect(result).toBe(true);
        });

        it('Should not be available in any tier if not available.', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [];
            const isRepair = true;

            // Act
            const resultOne = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_ONE
            );
            const resultTwo = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_TWO
            );
            const resultThree = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_THREE
            );

            // Assert
            expect(resultOne).toBe(false);
            expect(resultTwo).toBe(false);
            expect(resultThree).toBe(false);
        });

        it('Should not be available in tier 1', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [driverFrontWiperLineItem, passengerFrontWiperLineItem];
            const isRepair = true;

            // Act
            const result = servicePackageHelper.shouldFrontWipersBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_ONE
            );

            // Assert
            expect(result).toBe(false);
        });
    });

    describe('shouldRearWipersBeAvailable', () => {
        it('Should be available in tier 2 and 3 if rear damage and available', () => {
            // Arrange
            const damageLocations = [rearWindshieldGlass];
            const availableLineItems = [rearWiperLineItem];

            // Act
            const resultTwo = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_TWO
            );
            const resultThree = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_THREE
            );

            // Assert
            expect(resultTwo).toBe(true);
            expect(resultThree).toBe(true);
        });

        it('Should not be available in tier 2 if not rear damage', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [rearWiperLineItem];

            // Act
            const result = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_TWO
            );

            // Assert
            expect(result).toBe(false);
        });

        it('Should be available in tier 3 without rear damage, if available and no front wipers available', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [rearWiperLineItem];

            // Act
            const result = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_THREE
            );

            // Assert
            expect(result).toBe(true);
        });

        it('Should not be available in tier 3 without rear damage if front wipers are available', () => {
            // Arrange
            const damageLocations = [];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem
            ];

            // Act
            const result = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_THREE
            );

            // Assert
            expect(result).toBe(false);
        });

        it('Should not be available in any tier if not available', () => {
            // Arrange
            const damageLocations = [rearWindshieldGlass];
            const availableLineItems = [];

            // Act
            const resultOne = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_ONE
            );
            const resultTwo = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_TWO
            );
            const resultThree = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_THREE
            );

            // Assert
            expect(resultOne).toBe(false);
            expect(resultTwo).toBe(false);
            expect(resultThree).toBe(false);
        });

        it('Should not be available in tier 1', () => {
            // Arrange
            const damageLocations = [rearWindshieldGlass];
            const availableLineItems = [rearWiperLineItem];

            // Act
            const result = servicePackageHelper.shouldRearWipersBeAvailable(
                damageLocations,
                availableLineItems,
                packageNames.TIER_ONE
            );

            // Assert
            expect(result).toBe(false);
        });
    });

    describe('shouldRainDefenseBeAvailable', () => {
        it('Should generally be available only in tier 3', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                rainDefenseLineItem,
                driverFrontWiperLineItem,
                rearWiperLineItem,
                recalLineItem
            ];
            const isRepair = false;

            // Act
            const resultOne = servicePackageHelper.shouldRainDefenseBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_ONE
            );
            const resultTwo = servicePackageHelper.shouldRainDefenseBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_TWO
            );
            const resultThree = servicePackageHelper.shouldRainDefenseBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_THREE
            );

            // Assert
            expect(resultOne).toBe(false);
            expect(resultTwo).toBe(false);
            expect(resultThree).toBe(true);
        });

        it('Should not be available in a specific scenario', () => {
            // Arrange
            // SPECIFICALLY: no front windshield
            const damageLocations = [rearWindshieldGlass];
            const availableLineItems = [
                rainDefenseLineItem,
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem
            ];
            // SPECIFICALLY: not repair
            const isRepair = false;

            // Act
            const result = servicePackageHelper.shouldRainDefenseBeAvailable(
                damageLocations,
                availableLineItems,
                isRepair,
                packageNames.TIER_THREE
            );

            // Assert
            expect(result).toBe(false);
        });
    });

    describe('getLowestTierForType', () => {
        it('Should return the tier for items available in one tier only', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass, rearWindshieldGlass];

            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];

            const isRepair = false;

            // Act
            const result = servicePackageHelper.getLowestTierForType(
                damageLocations,
                availableLineItems,
                isRepair,
                partTypeStrings.RAIN_DEFENSE
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_THREE);
        });

        it('Should return tier 2 for items in tier 2 and 3', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass, rearWindshieldGlass];

            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];

            const isRepair = false;

            // Act
            const resultFront = servicePackageHelper.getLowestTierForType(
                damageLocations,
                availableLineItems,
                isRepair,
                partTypeStrings.FRONT_WIPER
            );
            const resultRear = servicePackageHelper.getLowestTierForType(
                damageLocations,
                availableLineItems,
                isRepair,
                partTypeStrings.REAR_WIPER
            );

            // Assert
            expect(resultFront).toEqual(packageNames.TIER_TWO);
            expect(resultRear).toEqual(packageNames.TIER_TWO);
        });

        it('Should return tier 1 for any item not in any tier', () => {
            // Arrange
            const damageLocations = [rearWindshieldGlass];

            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem
            ];

            const isRepair = false;

            // Act
            const resultFront = servicePackageHelper.getLowestTierForType(
                damageLocations,
                availableLineItems,
                isRepair,
                partTypeStrings.RAIN_DEFENSE
            );

            // Assert
            expect(resultFront).toEqual(packageNames.TIER_ONE);
        });
    });

    describe('getHighestRequiredTier', () => {
        it('Should return the highest tier among items', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem
            ];

            // Act
            const result = servicePackageHelper.getHighestRequiredTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_THREE);
        });

        it('Should not return a higher tier than items require', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [driverFrontWiperLineItem, passengerFrontWiperLineItem];

            // Act
            const result = servicePackageHelper.getHighestRequiredTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_TWO);
        });

        it('Should return tier 1 for empty set', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [];

            // Act
            const result = servicePackageHelper.getHighestRequiredTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_ONE);
        });

        it('Should return tier 1 if no vaps are part of tiers', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [recalLineItem];

            // Act
            const result = servicePackageHelper.getHighestRequiredTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_ONE);
        });
    });

    describe('getHighestSatisfiedTier', () => {
        it('Should return the highest tier if multiple are satisfied', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass, rearWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rainDefenseLineItem,
                rearWiperLineItem
            ];

            // Act
            const result = servicePackageHelper.getHighestFullySatisfiedTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_THREE);
        });

        it('Should only return *satisfied* tier', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [driverFrontWiperLineItem, passengerFrontWiperLineItem];

            // Act
            const result = servicePackageHelper.getHighestFullySatisfiedTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_TWO);
        });

        it('Should not return a tier if it is only partially satisfied', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [rainDefenseLineItem];

            // Act
            const result = servicePackageHelper.getHighestFullySatisfiedTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_ONE);
        });

        it('Should return tier 1 if no vaps are selected.', () => {
            // Arrange
            const damageLocations = [frontWindshieldGlass];
            const availableLineItems = [
                driverFrontWiperLineItem,
                passengerFrontWiperLineItem,
                rearWiperLineItem,
                rainDefenseLineItem
            ];
            const isRepair = false;
            const vaps = [];

            // Act
            const result = servicePackageHelper.getHighestFullySatisfiedTier(
                damageLocations,
                availableLineItems,
                isRepair,
                vaps
            );

            // Assert
            expect(result).toEqual(packageNames.TIER_ONE);
        });
    });
});
