Skip to content

Commit

Permalink
docs: suporte para rotas dinamicas no frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermefariah committed Oct 15, 2024
1 parent 8ee8a27 commit 61d0c86
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 14 deletions.
12 changes: 12 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@faker-js/faker": "^9.0.0",
"@hookform/error-message": "^2.0.1",
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/ui/alert-box/alert-boc.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { render, screen } from '@testing-library/react'
import { describe, it, expect } from 'vitest'

import { Status } from '@/app/(mentoring)/mentoring.type'

import { AlertBox } from './'

describe('AlertBox Component', () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/ui/button/button.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react'
import { describe, it, expect } from 'vitest'

import { Button } from '.'

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/ui/card/card.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Card.test.tsx
import React from 'react'
import { render, screen } from '@testing-library/react'
import React from 'react'
import { describe, it, expect, vi } from 'vitest'

import { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from '.'

describe('Card Components', () => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/ui/card/card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import Image from 'next/image'

import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './index'

Expand Down Expand Up @@ -57,7 +58,7 @@ export const WithImage: Story = {
render: () => (
<Card>
<CardHeader>
<img src="https://via.placeholder.com/150" alt="Placeholder Image" />
<Image src="https://via.placeholder.com/150" alt="Placeholder Image" />
<CardTitle>Card with Image</CardTitle>
<CardDescription>This card has an image in the header.</CardDescription>
</CardHeader>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen } from '@testing-library/react'
import { describe, it, expect } from 'vitest'

import { ErrorMessage } from './'

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/ui/input/input.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { fireEvent, render } from '@testing-library/react'
import React from 'react'
import { describe, expect } from 'vitest'

import { Input } from '.'

import React from 'react'


describe('<Input />', () => {
test('applies custom class', () => {
Expand Down
17 changes: 11 additions & 6 deletions frontend/src/infra/http/HttpClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { describe, it, expect, beforeEach } from 'vitest'
import axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios'
import { HttpMethod, HttpRequest } from './HttpClient.types'
import { describe, it, expect, beforeEach, vi } from 'vitest'

import { HttpAxiosAdapter } from './HttpClient'
import { HttpMethod, HttpRequest } from './HttpClient.types'


// Mock do axios
vi.mock('axios', () => ({
Expand All @@ -11,10 +13,12 @@ vi.mock('axios', () => ({
}))

describe('HttpAxiosAdapter', () => {
// @ts-expect-error
let mockAxios: { request: vi.Mock }
let httpClient: HttpAxiosAdapter

beforeEach(() => {
// @ts-expect-error
mockAxios = axios as unknown as { request: vi.Mock }
httpClient = new HttpAxiosAdapter(mockAxios as unknown as AxiosInstance)
})
Expand All @@ -25,7 +29,7 @@ describe('HttpAxiosAdapter', () => {
endpoint: '/test',
method: HttpMethod.GET,
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockResolvedValueOnce({
data: responseData,
} as AxiosResponse<typeof responseData>)
Expand All @@ -49,7 +53,7 @@ describe('HttpAxiosAdapter', () => {
body: { key: 'value' },
headers: { 'Content-Type': 'application/json' },
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockResolvedValueOnce({
data: responseData,
} as AxiosResponse<typeof responseData>)
Expand Down Expand Up @@ -78,7 +82,7 @@ describe('HttpAxiosAdapter', () => {
data: errorMessage,
},
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockRejectedValueOnce(errorResponse as AxiosError)

await expect(httpClient.request(request)).rejects.toThrow(
Expand All @@ -100,6 +104,7 @@ describe('HttpAxiosAdapter', () => {
}

const networkError = new Error('Network Error')
// @ts-expect-error
;(mockAxios.request as vi.Mock).mockRejectedValueOnce(networkError)

await expect(httpClient.request(request)).rejects.toThrow(
Expand All @@ -120,7 +125,7 @@ describe('HttpAxiosAdapter', () => {
endpoint: '/no-header-no-body',
method: HttpMethod.DELETE,
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockResolvedValueOnce({
data: responseData,
} as AxiosResponse<typeof responseData>)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it, expect } from 'vitest'

import { cn } from './utils' // Ajuste o caminho conforme necessário

describe('cn', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { describe, test, expect } from 'vitest'

import { MentoringAgendaService } from './MentoringAgenda.service'

import { SchemaMentoringType } from '@/app/(mentoring)/mentoring.type'
import {
httpClientMockFail,
httpClientMockSuccess,
mockResponse,
} from '@/tests/mock/httpClientMock'

import { MentoringAgendaService } from './MentoringAgenda.service'

const mockUserData: SchemaMentoringType = {
name: 'John Doe',
email: '[email protected]',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/tests/changeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fireEvent } from '@testing-library/react'
import { expect } from 'vitest'

type ChangeInputProps = {
input: HTMLInputElement
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/mock/mockSchemaMentoringTypeData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaMentoringType } from '../../app/(mentoring)/mentoring.type'
import { SchemaMentoringType } from '@/app/(mentoring)/mentoring.type'

export const mockSchemaMentoringTypeData: SchemaMentoringType = {
name: 'John Doe',
Expand Down
1 change: 1 addition & 0 deletions frontend/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolve } from 'path'

import react from '@vitejs/plugin-react'
import { defineConfig } from 'vitest/config'

Expand Down

0 comments on commit 61d0c86

Please sign in to comment.