require "test_helper"
require "elasticsearch/sitemap"

class SitemapGeneratorTest < MiniTest::Unit::TestCase
  def test_should_generate_sitemap
    sitemap = SitemapGenerator.new('')
    
    sitemap_xml = sitemap.generate_xml([ 'https://www.gov.uk/page', '/another-page', 'yet-another-page' ])
    doc = Nokogiri::XML(sitemap_xml)
    urls = doc.css('url > loc').map(&:inner_html)
    assert_equal urls[0], 'https://www.gov.uk/page'
    assert_equal urls[1], "http://www.#{ENV['DEV_DOMAIN']}/another-page"
    assert_equal urls[2], "http://www.#{ENV['DEV_DOMAIN']}/yet-another-page"
  end
end
