Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
owenatgov committed Oct 6, 2020
1 parent 637891a commit c818fc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
9 changes: 4 additions & 5 deletions app/views/datasets/_timeseries_data.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<%
accordion_items = []

group_and_order(datafiles).each do |year, datafiles|
accordion_items << {
accordion_items = group_and_order(datafiles).map do |year, datafiles|
{
heading: {
text: year.presence || t('.other_data_files')
},
Expand All @@ -14,5 +12,6 @@
%>

<%= render "govuk_publishing_components/components/accordion", {
id: "dgu-datafiles-year",
items: accordion_items
} %>
} %>
20 changes: 11 additions & 9 deletions spec/features/dataset_show_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,17 @@

scenario "are grouped by year when they contain timeseries datafiles" do
index_and_visit(dataset)
expect(page).to have_css(".dgu-datafiles__year", count: 2)

correct_order = [
Time.zone.parse(datafile2["start_date"]).year.to_s,
Time.zone.parse(datafile1["start_date"]).year.to_s,
]

actual_order = all("button.dgu-datafiles__year").map(&:text)
expect(actual_order).to eq correct_order
expect(page).to have_css("#dgu-datafiles-year")

within("#dgu-datafiles-year") do
correct_order = [
Time.zone.parse(datafile2["start_date"]).year.to_s,
Time.zone.parse(datafile1["start_date"]).year.to_s,
]

actual_order = all(".govuk-accordion__section-button").map(&:text)
expect(actual_order).to eq correct_order
end
end

scenario "are not grouped when they contain non timeseries datafiles" do
Expand Down

0 comments on commit c818fc7

Please sign in to comment.