Skip to content

Commit

Permalink
Add tests for EventPicker progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Billing committed Oct 1, 2020
1 parent 20295ff commit 304f4c7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tnoodle-ui/src/main/components/EventPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const EventPicker = connect(
}

return (
<ProgressBar animated fade variant={
<ProgressBar animated variant={
progress === 100
? "success"
: "info"
Expand Down
37 changes: 36 additions & 1 deletion tnoodle-ui/src/test/EventPicker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import { events } from "./mock/tnoodle.api.mock";

import { defaultWcif } from "../main/constants/default.wcif";

import { updateEditingStatus } from "../main/redux/ActionCreators";
import {
updateEditingStatus,
updateScramblingProgressTarget,
updateGeneratingScrambles
} from "../main/redux/ActionCreators";

let container = null;
beforeEach(() => {
Expand Down Expand Up @@ -138,3 +142,34 @@ it("Editing disabled", () => {
// Copies must be editable anyways
expect(copies.disabled).toBe(false);
});

it("Progress Bar showing/hiding", () => {
const store = createStore(Reducer);

const event = events[0];
const wcifEvent = defaultWcif.events[0]; // This is one round of 333

// Enforce that fields are not disabled
store.dispatch(updateEditingStatus(true));

// Render component
act(() => {
render(
<Provider store={store}>
<EventPicker event={event} wcifEvent={wcifEvent} />
</Provider>,
container
);
});

const progressBefore = Array.from(container.querySelectorAll("div.progress"));

expect(progressBefore.length).toBe(0);

store.dispatch(updateScramblingProgressTarget({[event.id]:3}));
store.dispatch(updateGeneratingScrambles(true));

const progressAfter = Array.from(container.querySelectorAll("div.progress"));

expect(progressAfter.length).toBe(1);
});

0 comments on commit 304f4c7

Please sign in to comment.