Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kojimena committed Nov 15, 2023
1 parent cf425ab commit bfddadc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
16 changes: 10 additions & 6 deletions uniEmpleos/src/pages/SignUpEmpresa/SignUpEmpresa.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import React, { useState } from "react"
import { useStoreon } from "storeon/react"
import { AiOutlineCloudDownload } from "react-icons/ai"
import { TbEdit } from "react-icons/tb"
import { useTranslation } from "react-i18next"
import style from "./SignUpEmpresa.module.css"
import ComponentInput from "../../components/Input/Input"
import TextArea from "../../components/textAreaAutosize/TextAreaAuto"
import Button from "../../components/Button/Button"
import { navigate } from "../../store"
import Popup from "../../components/Popup/Popup"
import useApi from "../../Hooks/useApi"
import { useStoreon } from "storeon/react"
import InputFile from "../../components/InputFile/InputFile"
import { AiOutlineCloudDownload } from "react-icons/ai"
import { TbEdit } from "react-icons/tb"
import Loader from "../../components/Loader/Loader"
import { useTranslation } from "react-i18next"

const SignUpEmpresa = () => {
const { t } = useTranslation()
Expand Down Expand Up @@ -91,7 +91,7 @@ const SignUpEmpresa = () => {

const usuario = await user.token
console.log(usuario)

if (pfp) {
const data = await apiPfp.updateProfilePicture(pfp)
if (data.status === 200) {
Expand Down Expand Up @@ -234,7 +234,11 @@ const SignUpEmpresa = () => {
</div>
</div>
<div className={style.buttonContainer}>
<Button label={t("signUpEmpresa.register")} onClick={signup} />
<Button
data-testid="signup-button"
label={t("signUpEmpresa.register")}
onClick={signup}
/>
</div>
</div>
</div>
Expand Down
26 changes: 4 additions & 22 deletions uniEmpleos/src/pages/SignUpEmpresa/SignUpEmpresa.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import useApi from "../../Hooks/useApi"
global.fetch = fetch

it("should call API and navigate to login page when valid form data is submitted", async () => {
//const api = useApi()
// const api = useApi()
const fetchSpy = vi.spyOn(window, "fetch").mockResolvedValue({
json: () => Promise.resolve({ status: 200, data: {token: "123"} }),
json: () => Promise.resolve({ status: 200, data: { token: "123" } }),
})
const navigateSpy = vi.spyOn(store, "dispatch")

const { getByPlaceholderText, getByText } = render(
const { getByPlaceholderText, getByTestId } = render(
<StoreContext.Provider value={store}>
<SignUpEmpresa />
</StoreContext.Provider>
Expand All @@ -40,23 +40,5 @@ it("should call API and navigate to login page when valid form data is submitted
target: { value: "Test company details" },
})

// Simulate form submission
fireEvent.click(getByText("Registrarse"))


// Check if the correct API call was made
// Wait for the signup process to complete
/* await waitFor(() => {
expect(api.handleRequest).toHaveBeenCalledWith('POST', '/companies', {
nombre: 'My Company',
detalles: '',
correo: 'company@example.com',
telefono: '12345678',
contra: 'password',
foto: '',
});
}); */

// Check if navigation to login page occurred
// expect(navigate).toHaveBeenCalledWith('/login');
fireEvent.click(getByTestId("signup-button"))
})

0 comments on commit bfddadc

Please sign in to comment.