Skip to content

Commit

Permalink
Fix tnoodle-ui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorbg committed Jul 27, 2022
1 parent 1b9f6ff commit 4e48039
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 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
9 changes: 7 additions & 2 deletions tnoodle-ui/src/test/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import App from "../App";
import tnoodleApi from "../main/api/tnoodle.api";
import wcaApi from "../main/api/wca.api";
import Translation from "../main/model/Translation";
import FrontendStatus from "../main/model/FrontendStatus";
import Wcif from "../main/model/Wcif";
import { defaultWcif } from "../main/util/wcif.util";
import {
bestMbldAttempt,
defaultStatus,
events,
formats,
languages,
Expand All @@ -29,6 +31,7 @@ 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 @@ -56,13 +59,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 @@ -131,6 +135,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 4e48039

Please sign in to comment.