Skip to content

Commit

Permalink
Adjusts in test files
Browse files Browse the repository at this point in the history
  • Loading branch information
campos20 committed Sep 19, 2020
1 parent 04d81c4 commit 41815b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
14 changes: 3 additions & 11 deletions tnoodle-ui/src/test/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,15 @@ beforeEach(() => {
).mockImplementation(() => Promise.resolve(languages));

jest.spyOn(tnoodleApi, "fetchRunningVersion").mockImplementation(() =>
Promise.resolve({
json: () => Promise.resolve(version),
})
Promise.resolve(version)
);

jest.spyOn(tnoodleApi, "fetchZip").mockImplementation((...payload) => {
wcif = payload[0];
mbld = payload[1];
password = payload[2];
translations = payload[3];
return Promise.resolve(scrambleProgram);
return Promise.resolve(new Blob([]));
});

jest.spyOn(wcaApi, "fetchVersionInfo").mockImplementation(() =>
Expand Down Expand Up @@ -293,11 +291,6 @@ it("Online user", async () => {
"fetchSuggestedFmcTranslations"
).mockImplementation(() => Promise.resolve(["de", "es", "pt-BR"]));

jest.spyOn(tnoodleApi, "fetchZip").mockImplementation(() => {
console.log("Generating zip");
return Promise.resolve(new Blob());
});

// Render component
await act(async () => {
render(
Expand Down Expand Up @@ -331,6 +324,5 @@ it("Online user", async () => {
wcaApi.fetchMe.mockRestore();
wcaApi.getCompetitionJson.mockRestore();
tnoodleApi.fetchBestMbldAttempt.mockRestore();
tnoodleApi.fetchSuggestedFmcTranslations.mockRestore();
tnoodleApi.fetchZip.mockRestore();*/
tnoodleApi.fetchSuggestedFmcTranslations.mockRestore();*/
});
15 changes: 14 additions & 1 deletion tnoodle-ui/src/test/Main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,35 @@ import {

import Main from "../main/components/Main";

import { events, languages, formats } from "./mock/tnoodle.api.mock";
import { events, languages, formats, version } from "./mock/tnoodle.api.mock";
import { scrambleProgram } from "./mock/wca.api.mock";

const tnoodleApi = require("../main/api/tnoodle.api");
const wcaApi = require("../main/api/wca.api");

let container = null;
beforeEach(() => {
// setup a DOM element as a render target
container = document.createElement("div");
document.body.appendChild(container);

jest.spyOn(tnoodleApi, "fetchRunningVersion").mockImplementation(() =>
Promise.resolve(version)
);

jest.spyOn(wcaApi, "fetchVersionInfo").mockImplementation(() =>
Promise.resolve(scrambleProgram)
);
});

afterEach(() => {
// cleanup on exiting
unmountComponentAtNode(container);
container.remove();
container = null;

tnoodleApi.fetchRunningVersion.mockRestore();
wcaApi.fetchVersionInfo.mockRestore();
});

it("There should be only 1 button of type submit, check FMC changes", async () => {
Expand Down

0 comments on commit 41815b9

Please sign in to comment.