Skip to content

Commit

Permalink
Add rspec testss for auto_close
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisaShapiro committed Jan 30, 2025
1 parent 507fea1 commit 1295fec
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
.with_default(nil)
.with_values(nil, "top", "bottom")
}
it { is_expected.to define_prop(:auto_close).of_type(Playbook::Props::Number) }

describe "#show_text?" do
it "returns true if text is present", :aggregate_failures do
Expand Down Expand Up @@ -56,6 +57,14 @@
end
end

describe "#auto_close" do
it "returns auto close class with duration when auto_close is present" do
expect(subject.new({}).auto_close_class).to eq ""
expect(subject.new(auto_close: 3000).auto_close_class).to eq " auto_close_3000"
expect(subject.new(auto_close: 10000).auto_close_class).to eq " auto_close_10000"
end
end

describe "#classname" do
it "returns namespaced class name", :aggregate_failures do
text = "Test text"
Expand All @@ -70,6 +79,7 @@
expect(subject.new(text: text, status: "neutral", vertical: "top").classname).to eq "pb_fixed_confirmation_toast_kit_neutral"
expect(subject.new(text: text, status: "neutral", vertical: "top", horizontal: "center").classname).to eq "pb_fixed_confirmation_toast_kit_neutral positioned_toast top center"
expect(subject.new(text: text, status: "tip", icon: "arrow-down").classname).to eq "pb_fixed_confirmation_toast_kit_tip custom_icon"
expect(subject.new(text: text, status: "tip", auto_close: 3000).classname).to eq "pb_fixed_confirmation_toast_kit_tip auto_close_3000"
end
end
end

0 comments on commit 1295fec

Please sign in to comment.