Skip to content

Commit

Permalink
Add spec for appending checkmark
Browse files Browse the repository at this point in the history
  • Loading branch information
jennmiller committed Feb 4, 2020
1 parent 25c5034 commit ffde83f
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions test/components/group_label_input_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import sinon from "sinon"
import GroupLabelInput from "../../web/static/js/components/group_label_input"

describe("GroupLabelInput component", () => {
let wrapper
let groupWithAssociatedIdeasAndVotes

describe("upon blurring the input field", () => {
let submitGroupLabelChangesSpy
let groupWithAssociatedIdeasAndVotes

beforeEach(() => {
groupWithAssociatedIdeasAndVotes = {
Expand All @@ -18,7 +20,7 @@ describe("GroupLabelInput component", () => {
}

submitGroupLabelChangesSpy = sinon.spy()
const wrapper = shallow(
wrapper = shallow(
<GroupLabelInput
groupWithAssociatedIdeasAndVotes={groupWithAssociatedIdeasAndVotes}
actions={{ submitGroupLabelChanges: submitGroupLabelChangesSpy }}
Expand All @@ -35,4 +37,31 @@ describe("GroupLabelInput component", () => {
).to.have.been.calledWith(groupWithAssociatedIdeasAndVotes, "Turtles")
})
})

describe("upon the group label changing", () => {
it("adds a checkmark next to the label", () => {
groupWithAssociatedIdeasAndVotes = {
id: 777,
label: "some previous label",
ideas: [],
votes: [],
}
wrapper = shallow(
<GroupLabelInput
groupWithAssociatedIdeasAndVotes={groupWithAssociatedIdeasAndVotes}
actions={{}}
/>
)
const newGroupWithAssociatedIdeasAndVotes = {
id: 777,
label: "a better label",
ideas: [],
votes: [],
}

expect(wrapper.find(".check")).to.have.lengthOf(0)
wrapper.setProps({ groupWithAssociatedIdeasAndVotes: newGroupWithAssociatedIdeasAndVotes })
expect(wrapper.find(".check")).to.have.lengthOf(1)
})
})
})

0 comments on commit ffde83f

Please sign in to comment.