|
1 | 1 | require "rails_helper" |
2 | 2 |
|
3 | 3 | describe CertificateHelper, type: :helper do |
| 4 | + let(:user) { create(:user) } |
| 5 | + let(:programme_activity_grouping) { create(:programme_activity_grouping) } |
| 6 | + let(:other_programme_activity_grouping) { create(:programme_activity_grouping) } |
| 7 | + |
| 8 | + describe "#add_group_complete_icon_class" do |
| 9 | + it "should return blank if user not completed" do |
| 10 | + allow_any_instance_of(ProgrammeActivityGrouping).to receive(:user_complete?).and_return(false) |
| 11 | + expect(helper.add_group_complete_icon_class(user, programme_activity_grouping)).to be_blank |
| 12 | + end |
| 13 | + |
| 14 | + it "should return class if user completed" do |
| 15 | + allow_any_instance_of(ProgrammeActivityGrouping).to receive(:user_complete?).and_return(true) |
| 16 | + expect(helper.add_group_complete_icon_class(user, programme_activity_grouping)).to eq("ncce-activity-list__title--complete") |
| 17 | + end |
| 18 | + end |
| 19 | + |
| 20 | + describe "#add_groups_complete_icon_class" do |
| 21 | + it "should return blank if not all groups are complete" do |
| 22 | + allow(programme_activity_grouping).to receive(:user_complete?).and_return(false) |
| 23 | + allow(other_programme_activity_grouping).to receive(:user_complete?).and_return(true) |
| 24 | + expect(helper.add_groups_complete_icon_class(user, [programme_activity_grouping, other_programme_activity_grouping])).to be_blank |
| 25 | + end |
| 26 | + |
| 27 | + it "should return class if all groups complete" do |
| 28 | + allow(programme_activity_grouping).to receive(:user_complete?).and_return(true) |
| 29 | + allow(other_programme_activity_grouping).to receive(:user_complete?).and_return(true) |
| 30 | + expect(helper.add_groups_complete_icon_class(user, [programme_activity_grouping, other_programme_activity_grouping])).to eq("ncce-activity-list__title--complete") |
| 31 | + end |
| 32 | + end |
4 | 33 | end |
0 commit comments