Skip to content

Commit

Permalink
Fix tnoodle-ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorbg authored and Gregor Billing committed Jun 27, 2021
1 parent a57d58a commit 6af2b70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tnoodle-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ val yarnInstall = tasks.named("yarn_install") {
val yarnBuild = tasks.named("yarn_build") {
dependsOn(yarnInstall)

inputs.files(fileTree("src").exclude("*.css"))
inputs.files(fileTree("src/main").exclude("*.css"))
inputs.dir("public")
inputs.file("package.json")

Expand Down
16 changes: 7 additions & 9 deletions tnoodle-ui/src/test/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { configureStore } from "@reduxjs/toolkit";
import { fireEvent } from "@testing-library/react";
import { shuffle } from "lodash";
import React from "react";
Expand All @@ -10,15 +9,10 @@ import tnoodleApi from "../main/api/tnoodle.api";
import wcaApi from "../main/api/wca.api";
import Translation from "../main/model/Translation";
import Wcif from "../main/model/Wcif";
import { competitionSlice } from "../main/redux/slice/CompetitionSlice";
import { fmcSlice } from "../main/redux/slice/FmcSlice";
import { informationSlice } from "../main/redux/slice/InformationSlice";
import { mbldSlice } from "../main/redux/slice/MbldSlice";
import { scramblingSlice } from "../main/redux/slice/ScramblingSlice";
import { wcifSlice } from "../main/redux/slice/WcifSlice";
import { defaultWcif } from "../main/util/wcif.util";
import {
bestMbldAttempt,
defaultStatus,
events,
formats,
languages,
Expand All @@ -32,12 +26,14 @@ import {
scrambleProgram,
wcifs,
} from "./mock/wca.api.test.mock";
import FrontendStatus from "../main/model/FrontendStatus";

let container = document.createElement("div");

let wcif: Wcif | null = null;
let mbld: string | null = null;
let password: string | null = null;
let status: FrontendStatus | null = null;
let translations: Translation[] | undefined;
beforeEach(() => {
// setup a DOM element as a render target
Expand Down Expand Up @@ -68,13 +64,14 @@ beforeEach(() => {
);

jest.spyOn(tnoodleApi, "fetchZip").mockImplementation(
(scrambleClient, _wcif, _mbld, _password, _translations) => {
(scrambleClient, _wcif, _mbld, _password, _status, _translations) => {
wcif = _wcif;
mbld = _mbld;
password = _password;
status = _status;
translations = _translations;

return Promise.resolve({ ...axiosResponse, data: plainZip });
return Promise.resolve(plainZip);
}
);

Expand Down Expand Up @@ -147,6 +144,7 @@ it("Just generate scrambles", async () => {
expect(wcif!.events.length).toBe(1);

expect(password).toBe("");
expect(status).toEqual(defaultStatus);
});

it("Changes on 333, scramble", async () => {
Expand Down
7 changes: 7 additions & 0 deletions tnoodle-ui/src/test/mock/tnoodle.api.test.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export const plainZip = {
payload: "UEsDBBQACAgIAK...",
};

export const defaultStatus = {
isStaging: false,
isManual: true,
isSignedBuild: true,
isAllowedVersion: true,
};

export const bestMbldAttempt = {
solved: 60,
attempted: 60,
Expand Down

0 comments on commit 6af2b70

Please sign in to comment.