defmodule BoutiqueInventoryTest do
  use ExUnit.Case

  describe "sort_by_price/1" do
    # @tag :pending
    test "works for an empty inventory" do
      assert BoutiqueInventory.sort_by_price([]) == []
    end

    @tag :pending
    test "sorts items by price" do
      assert BoutiqueInventory.sort_by_price([
               %{price: 65, name: "Maxi Yellow Summer Dress", quantity_by_size: %{}},
               %{price: 60, name: "Cream Linen Pants", quantity_by_size: %{}},
               %{price: 33, name: "Straw Hat", quantity_by_size: %{}},
               %{price: 60, name: "Brown Linen Pants", quantity_by_size: %{}}
             ]) == [
               %{price: 33, name: "Straw Hat", quantity_by_size: %{}},
               %{price: 60, name: "Cream Linen Pants", quantity_by_size: %{}},
               %{price: 60, name: "Brown Linen Pants", quantity_by_size: %{}},
               %{price: 65, name: "Maxi Yellow Summer Dress", quantity_by_size: %{}}
             ]
    end
  end

  describe "with_missing_price/1" do
    @tag :pending
    test "works for an empty inventory" do
      assert BoutiqueInventory.with_missing_price([]) == []
    end

    @tag :pending
    test "filters out items that do have a price" do
      assert BoutiqueInventory.with_missing_price([
               %{name: "Red Flowery Top", price: 50, quantity_per_size: %{}},
               %{name: "Purple Flowery Top", price: nil, quantity_per_size: %{}},
               %{name: "Bamboo Socks Avocado", price: 10, quantity_per_size: %{}},
               %{name: "Bamboo Socks Palm Trees", price: 10, quantity_per_size: %{}},
               %{name: "Bamboo Socks Kittens", price: nil, quantity_per_size: %{}}
             ]) == [
               %{name: "Purple Flowery Top", price: nil, quantity_per_size: %{}},
               %{name: "Bamboo Socks Kittens", price: nil, quantity_per_size: %{}}
             ]
    end
  end

  describe "increase_quantity/2" do
    @tag :pending
    test "works for an empty quantity map" do
      assert BoutiqueInventory.increase_quantity(
               %{
                 name: "Long Black Evening Dress",
                 price: 105,
                 quantity_by_size: %{}
               },
               1
             ) == %{
               name: "Long Black Evening Dress",
               price: 105,
               quantity_by_size: %{}
             }
    end

    @tag :pending
    test "sorts items by price" do
      assert BoutiqueInventory.increase_quantity(
               %{
                 name: "Green Swimming Shorts",
                 price: 46,
                 quantity_by_size: %{s: 1, m: 2, l: 4, xl: 1}
               },
               3
             ) == %{
               name: "Green Swimming Shorts",
               price: 46,
               quantity_by_size: %{s: 4, m: 5, l: 7, xl: 4}
             }
    end
  end

  describe "total_quantity/1" do
    @tag :pending
    test "works for an empty quantity map" do
      assert BoutiqueInventory.total_quantity(%{
               name: "Red Denim Pants",
               price: 77,
               quantity_by_size: %{}
             }) == 0
    end

    @tag :pending
    test "sums up total quantity" do
      assert BoutiqueInventory.total_quantity(%{
               name: "Black Denim Skirt",
               price: 50,
               quantity_by_size: %{s: 4, m: 11, l: 6, xl: 8}
             }) == 29
    end
  end
end
