require 'test_helper'

module PublishingApi
  module PayloadBuilder
    class PayloadBuilderFirstPublishedAtTest < ActiveSupport::TestCase
      def test_returns_first_published_at_if_present
        first_published_at = Object.new
        item = stub(first_published_at: first_published_at)

        assert_equal(
          { first_published_at: first_published_at },
          FirstPublishedAt.for(item)
        )
      end
    end
  end
end

require 'test_helper'

module PublishingApi
  module PayloadBuilder
    class PayloadBuilderFirstPublishedAtTest < ActiveSupport::TestCase
      def test_returns_first_published_at_if_present
        first_published_at = Object.new
        item = stub(first_published_at: first_published_at)

        assert_equal(
          { first_published_at: first_published_at },
          FirstPublishedAt.for(item)
        )
      end

      def test_returns_nil_created_at_for_nil_first_published_at
        created_at = Object.new
        item = stub(first_published_at: nil, document: stub(created_at: created_at))

        assert_empty(FirstPublishedAt.for(item))
      end
    end
  end
end

Bring back test for first published at
Bring back test for first published at

This test was removed as part of some changes but
we want to ensure that the created at of the document
is not sent to the Publishing API
