require 'rails_helper'

RSpec.describe "transactions/sales/index", type: :view do
  before(:each) do
    assign(:transactions_sales, [
      Transactions::Sale.create!(
        :cashier => nil,
        :cashier_name => "Cashier Name",
        :requested_by => "Requested By",
        :receipt_no => "Receipt No",
        :customer => nil,
        :payment_status => "Payment Status",
        :sale_status => "Sale Status",
        :total_amount => "9.99",
        :total_discount => "9.99",
        :total_tax => "9.99",
        :tax_type => "Tax Type",
        :grand_total => "9.99",
        :rounding_adjustment => "9.99",
        :amount_received => "9.99",
        :amount_changed => "9.99"
      ),
      Transactions::Sale.create!(
        :cashier => nil,
        :cashier_name => "Cashier Name",
        :requested_by => "Requested By",
        :receipt_no => "Receipt No",
        :customer => nil,
        :payment_status => "Payment Status",
        :sale_status => "Sale Status",
        :total_amount => "9.99",
        :total_discount => "9.99",
        :total_tax => "9.99",
        :tax_type => "Tax Type",
        :grand_total => "9.99",
        :rounding_adjustment => "9.99",
        :amount_received => "9.99",
        :amount_changed => "9.99"
      )
    ])
  end

  it "renders a list of transactions/sales" do
    render
    assert_select "tr>td", :text => nil.to_s, :count => 2
    assert_select "tr>td", :text => "Cashier Name".to_s, :count => 2
    assert_select "tr>td", :text => "Requested By".to_s, :count => 2
    assert_select "tr>td", :text => "Receipt No".to_s, :count => 2
    assert_select "tr>td", :text => nil.to_s, :count => 2
    assert_select "tr>td", :text => "Payment Status".to_s, :count => 2
    assert_select "tr>td", :text => "Sale Status".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
    assert_select "tr>td", :text => "Tax Type".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
    assert_select "tr>td", :text => "9.99".to_s, :count => 2
  end
end
