Sha256: 4e5dd530f609da271c3c6ee72998d3698cb111dad83882df9fe997e34eff2090

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module SocialNetworking
  module Concerns
    # Spec for profile page feed functionality.
    module ProfilePage
      describe Feed do
        let(:participant) do
          instance_double(::Participant, id: 1)
        end

        def items(page)
          Feed.new(participant_id: participant.id,
                   page: page).page_items
        end

        describe "when feed items exist" do
          before do
            allow(Serializers::NudgeSerializer)
              .to receive(:from_collection)
              .and_return([
                            { createdAtRaw: "" },
                            { createdAtRaw: "" }
                          ])
            allow(Serializers::OnTheMindStatementSerializer)
              .to receive(:from_collection)
              .and_return([
                            { createdAtRaw: "" },
                            { createdAtRaw: "" }
                          ])
            allow(Serializers::SharedItemSerializer)
              .to receive(:from_collection)
              .and_return([
                            { createdAtRaw: "" },
                            { createdAtRaw: "" }
                          ])
          end

          it "returns only 5 items on first request" do
            expect(items(0).count).to eq 5
          end

          it "returns the next item(s) on second request" do
            expect(items(1).count).to eq 1
          end
        end

        describe "when no feed items exist" do
          it "returns empty array" do
            expect(items(0)).to eq []
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
social_networking-0.13.0 spec/controllers/social_networking/concerns/profile_page/feed_spec.rb
social_networking-0.12.0 spec/controllers/social_networking/concerns/profile_page/feed_spec.rb