require 'rails_helper'

RSpec.describe "bots/index", type: :view do
  before(:each) do
    assign(:bots, [
      Bot.create!(
        name: "Name",
        telegram_api_token: "Telegram Api Token",
        discord_api_token: "Discord Api Token",
        user: nil,
        profile: nil
      ),
      Bot.create!(
        name: "Name",
        telegram_api_token: "Telegram Api Token",
        discord_api_token: "Discord Api Token",
        user: nil,
        profile: nil
      )
    ])
  end

  it "renders a list of bots" do
    render
    cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
    assert_select cell_selector, text: Regexp.new("Name".to_s), count: 2
    assert_select cell_selector, text: Regexp.new("Telegram Api Token".to_s), count: 2
    assert_select cell_selector, text: Regexp.new("Discord Api Token".to_s), count: 2
    assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2
    assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2
  end
end
