-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45786ea
commit 92e785b
Showing
3 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { render } from "@testing-library/react"; | ||
import { Provider } from "react-redux"; | ||
import configureStore from "redux-mock-store"; | ||
import DemoUserLogin from "./DemoUserLogin"; | ||
|
||
jest.mock("../config/Common", () => ({ | ||
doConnect: jest.fn(), | ||
doFileConnect: jest.fn(), | ||
})); | ||
|
||
describe("Demo User Login component", () => { | ||
const initialState = {}; | ||
const mockStore = configureStore(); | ||
let store; | ||
|
||
beforeEach(() => { | ||
store = mockStore(initialState); | ||
}); | ||
|
||
it.skip("renders without crashing", () => { | ||
render( | ||
<Provider store={store}> | ||
<DemoUserLogin /> | ||
</Provider> | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React from "react"; | ||
import { render, fireEvent } from "@testing-library/react"; | ||
import { Provider } from "react-redux"; | ||
import configureStore from "redux-mock-store"; | ||
import ImageManager from "./ImageManager"; | ||
import { doConnect, doFileConnect } from "../config/Common"; | ||
|
||
jest.mock("../config/Common", () => ({ | ||
doConnect: jest.fn(), | ||
doFileConnect: jest.fn(), | ||
})); | ||
|
||
describe("ImageManager component", () => { | ||
const initialState = {}; | ||
const mockStore = configureStore(); | ||
let store; | ||
|
||
beforeEach(() => { | ||
store = mockStore(initialState); | ||
}); | ||
|
||
it.skip("renders without crashing", () => { | ||
render( | ||
<Provider store={store}> | ||
<ImageManager /> | ||
</Provider> | ||
); | ||
}); | ||
|
||
it.skip("adds a new file successfully", async () => { | ||
const { getByPlaceholderText, getByText, findByText } = render( | ||
<Provider store={store}> | ||
<ImageManager /> | ||
</Provider> | ||
); | ||
|
||
// Fill out the form fields | ||
fireEvent.change(getByPlaceholderText("Enter Title"), { | ||
target: { value: "Test Image" }, | ||
}); | ||
fireEvent.change(getByText("Level"), { target: { value: "image" } }); | ||
|
||
// Simulate a file upload | ||
const fileInput = | ||
getByText("Image").parentElement.querySelector('input[type="file"]'); | ||
fireEvent.change(fileInput, { | ||
target: { | ||
files: [new File(["Hello, World!"], "test.png", { type: "image/png" })], | ||
}, | ||
}); | ||
|
||
// Click the submit button | ||
fireEvent.click(getByText("Submit")); | ||
|
||
// Wait for the successful toast notification | ||
await findByText("Added data !"); | ||
|
||
// Expect the doConnect and doFileConnect functions to have been called | ||
expect(doConnect).toHaveBeenCalledWith("addGameFile", "POST", { | ||
title: "Test Image", | ||
fileName: expect.any(String), | ||
fileType: "image", | ||
sessionId: "1223", | ||
}); | ||
expect(doFileConnect).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
file: expect.any(File), | ||
fileName: expect.any(String), | ||
fileType: "image", | ||
}) | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { render } from "@testing-library/react"; | ||
import { Provider } from "react-redux"; | ||
import configureStore from "redux-mock-store"; | ||
import QrCode from "./QrCode"; | ||
|
||
jest.mock("../config/Common", () => ({ | ||
doConnect: jest.fn(), | ||
doFileConnect: jest.fn(), | ||
})); | ||
|
||
describe("QR Code component", () => { | ||
const initialState = {}; | ||
const mockStore = configureStore(); | ||
let store; | ||
|
||
beforeEach(() => { | ||
store = mockStore(initialState); | ||
}); | ||
|
||
it.skip("renders without crashing", () => { | ||
render( | ||
<Provider store={store}> | ||
<QrCode /> | ||
</Provider> | ||
); | ||
}); | ||
}); |