Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
campos20 committed Dec 25, 2020
1 parent c73316e commit 982ce2a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions tnoodle-ui/src/test/EventPicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,29 @@ it("Changing values from event", () => {
numberOfRounds
);

// There's a harmless change of type here. 1 -> "1"
// Initial value should be 1
expect(store.getState().wcif.events[0].rounds[0].scrambleSetCount).toBe(1);

// This should be numberOfRounds * 2, since each round has 2 inputs.
// It's not, probably because not updating DOM after dispatching
const inputs = Array.from(container.querySelectorAll("input"));

let roundToChange = 0;
let value = "10";

// Change last scramble sets to 10
fireEvent.change(inputs[inputs.length - 2], { target: { value: 10 } });
fireEvent.change(inputs[roundToChange * 2], { target: { value } });
expect(
store.getState().wcif.events[0].rounds[numberOfRounds - 1]
.scrambleSetCount
).toEqual("10");
store.getState().wcif.events[0].rounds[roundToChange].scrambleSetCount
).toEqual(value);

// Remove 1 round
numberOfRounds--;
fireEvent.change(roundsSelector, { target: { value: numberOfRounds } });
expect(store.getState().wcif.events[0].rounds.length).toEqual(
numberOfRounds
);
expect(
store.getState().wcif.events[0].rounds[numberOfRounds - 1]
.scrambleSetCount
).not.toEqual("10");

const scrambleSets = inputs[0];
const copies = inputs[1];
Expand All @@ -89,11 +93,6 @@ it("Changing values from event", () => {
expect(scrambleSets.disabled).toBe(false);
expect(copies.disabled).toBe(false);

// There's a harmless change of type here. 1 -> "1"

// Initial value should be 1
expect(store.getState().wcif.events[0].rounds[0].scrambleSetCount).toBe(1);

// Changes to scrambleSet should go to the store
const newScrambleSets = "3";
fireEvent.change(scrambleSets, { target: { value: newScrambleSets } });
Expand Down

0 comments on commit 982ce2a

Please sign in to comment.