require 'spec_helper'

describe "Notification Subpanel", :js => true, :type => :feature, :capybara_feature => true  do

  subject { page }


  let(:user) { FactoryGirl.create(:user, last_jam_locidispid: 1) }



  describe "user with no notifications" do
    before(:each) do
      fast_signin(user, "/client")
    end

    it "lists no notifications" do
      open_notifications
      expect(page).to have_selector("#{NOTIFICATION_PANEL} li.notification-entry", count: 0)
    end
  end

  describe "user with 1 notification" do

    let!(:other) { FactoryGirl.create(:user, last_jam_locidispid: 1) }
    let!(:msg1) {FactoryGirl.create(:notification_text_message, source_user: other, target_user: user) }

    before(:each) do
      fast_signin(user, "/client")

    end

    it "lists 1 notifications" do
      open_notifications
      expect(page).to have_selector("#{NOTIFICATION_PANEL} li.notification-entry", count: 1)
    end
  end
end