Skip to content

Commit

Permalink
Added tests, rails and react
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisaShapiro committed Jul 17, 2024
1 parent bfff9ed commit 316ab8d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
31 changes: 22 additions & 9 deletions playbook/app/pb_kits/playbook/pb_icon/icon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("Icon Kit", () => {
data={{ testid: testId }}
fixedWidth
icon="user"
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -27,7 +27,7 @@ describe("Icon Kit", () => {
fixedWidth
icon="user"
rotation={rotateProp}
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -44,7 +44,7 @@ describe("Icon Kit", () => {
fixedWidth
flip="horizontal"
icon="user"
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -59,7 +59,7 @@ describe("Icon Kit", () => {
fixedWidth
icon="spinner"
spin
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -73,7 +73,7 @@ describe("Icon Kit", () => {
fixedWidth
icon="arrow-left"
pull="left"
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -87,7 +87,7 @@ describe("Icon Kit", () => {
fixedWidth
icon="arrow-left"
pull="left"
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -101,7 +101,7 @@ describe("Icon Kit", () => {
data={{ testid: testId }}
fixedWidth
icon="user"
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -128,7 +128,7 @@ describe("Icon Kit", () => {
data={{ testid: testId }}
icon="user"
size={sizeProp}
/>
/>
)

const kit = screen.getByTestId(testId)
Expand All @@ -145,11 +145,24 @@ describe("Icon Kit", () => {
fixedWidth
fontStyle="fas"
icon="user"
/>
/>
)

const kit = screen.getByTestId(testId)
expect(kit).toHaveClass("fa-user pb_icon_kit fa-fw fas")
})

test("renders with color prop", () => {
render(
<Icon
color="primary"
data={{ testid: testId }}
icon="user"
/>
)

const kit = screen.getByTestId(testId)
expect(kit).toHaveClass("color_primary")
})

})
16 changes: 16 additions & 0 deletions playbook/spec/pb_kits/playbook/kits/icon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
is_expected.to define_prop(:spin)
.of_type(Playbook::Props::Boolean)
}
it {
is_expected.to define_prop(:color)
.of_type(Playbook::Props::String)
.with_default(nil)
}

describe "#custom_icon" do
it "returns an icon with custom data-collapsible-main attribute", :aggregate_failures do
Expand Down Expand Up @@ -83,5 +88,16 @@
expect(subject.new(icon: icon, spin: true).classname).to eq "pb_icon_kit far fa-user fa-spin"
expect(subject.new(icon: icon, classname: "additional_class").classname).to eq "pb_icon_kit far fa-user additional_class"
end
it "includes color class when color prop is provided", :aggregate_failures do
icon = "user"
color = "primary"

expect(subject.new(icon: icon, color: color).classname).to include "color_primary"
end
it "does not include color class when color prop is not provided", :aggregate_failures do
icon = "user"

expect(subject.new(icon: icon).classname).not_to include "color_"
end
end
end

0 comments on commit 316ab8d

Please sign in to comment.