Skip to content

Commit

Permalink
Refactoring tests and ignoring utils tests to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusSanchez committed Feb 4, 2024
1 parent 7eedbfb commit e5739e9
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/controller/project/createProject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import request from 'supertest'
import { app } from '../../app'
import { randomUUID } from 'crypto'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let userAuth: {
token: string
Expand Down Expand Up @@ -50,6 +50,7 @@ describe('createProject E2E', () => {
const response = await request(app.server)
.post(`/user/${userId}/project`)
.send(createProjectBody)

.set('Authorization', `Bearer ${userAuth.token}`)

expect(response.body.message).toContain('User was not Found !')
Expand Down
2 changes: 1 addition & 1 deletion src/controller/project/deleteProjectById.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ProjectRepository } from '../../repositories/project-repository'
import { PrismaProjectRepository } from '../../repositories/prisma/prisma-project-repository'
import { app } from '../../app'
import { randomUUID } from 'crypto'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let projectRepository: ProjectRepository

Expand Down
2 changes: 1 addition & 1 deletion src/controller/project/editProject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import request from 'supertest'
import { app } from '../../app'
import { randomUUID } from 'crypto'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let userAuth: {
token: string
Expand Down
2 changes: 1 addition & 1 deletion src/controller/project/getProjectById.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProjectRepository } from '../../repositories/project-repository'
import { PrismaProjectRepository } from '../../repositories/prisma/prisma-project-repository'

import { randomUUID } from 'crypto'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let projectRepository: ProjectRepository

Expand Down
2 changes: 1 addition & 1 deletion src/controller/project/getProjectsByTags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import request from 'supertest'
import { app } from '../../app'

import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'
let userAuth: {
token: string
userId: string
Expand Down
2 changes: 1 addition & 1 deletion src/controller/project/getProjectsByUserId.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { app } from '../../app'
import { ProjectRepository } from '../../repositories/project-repository'
import { PrismaProjectRepository } from '../../repositories/prisma/prisma-project-repository'
import { randomUUID } from 'crypto'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let projectRepository: ProjectRepository

Expand Down
2 changes: 1 addition & 1 deletion src/controller/user/editUserById.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import request from 'supertest'
import { app } from '../../app'
import { randomUUID } from 'crypto'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let userAuth: {
token: string
Expand Down
2 changes: 1 addition & 1 deletion src/controller/user/getUserByEmail.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
import request from 'supertest'
import { app } from '../../app'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'

let userAuth: {
token: string
Expand Down
2 changes: 1 addition & 1 deletion src/controller/user/getUserById.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import request from 'supertest'
import { app } from '../../app'
import { createAndAuthenticateUser } from '../../utils/create-and-authenticate-user'
import { createAndAuthenticateUser } from '../../utils/tests/create-and-authenticate-user'
import { randomUUID } from 'crypto'

let userAuth: {
Expand Down
7 changes: 6 additions & 1 deletion src/use-cases/project/getProjectsByIdUseCase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { expect, describe, it, beforeEach } from 'vitest'
import { InMemoryProjectRepository } from '../../repositories/in-memory-db/inMemoryProjectRepository'
import { ResourceNotFoundError } from '../errors/ResourceNotFoundError'
import { GetProjectsByIdUseCase } from './getProjectsByIdUseCase'
import { defaultUserAvatarUrl } from '../../utils/tests/defaultUserAvatarUrl'

let projectRepository: InMemoryProjectRepository
let getProjectByIdUseCase: GetProjectsByIdUseCase
Expand Down Expand Up @@ -37,7 +38,11 @@ describe('Get Project By Id Use Case', () => {
title: 'React Typescript 1',
id: newProject.id,
tags: ['react', 'node'],
user: { name: 'John', surname: 'Doe', avatar_url: null },
user: {
name: 'John',
surname: 'Doe',
avatar_url: defaultUserAvatarUrl,
},
}),
)
})
Expand Down
15 changes: 8 additions & 7 deletions src/use-cases/project/getProjetsByTagsUseCase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InMemoryProjectRepository } from '../../repositories/in-memory-db/inMem

import { GetProjectsByTagsUseCase } from './getProjetsByTagsUseCase'
import { User } from '@prisma/client'
import { defaultUserAvatarUrl } from '../../utils/tests/defaultUserAvatarUrl'

let projectRepository: InMemoryProjectRepository
let getProjectsByTagsUseCase: GetProjectsByTagsUseCase
Expand Down Expand Up @@ -49,7 +50,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
tags: ['react', 'node', 'typescript'],
}),
Expand Down Expand Up @@ -92,7 +93,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
}),
)
Expand All @@ -103,7 +104,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
}),
)
Expand All @@ -114,7 +115,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
}),
)
Expand Down Expand Up @@ -156,7 +157,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
}),
)
Expand All @@ -167,7 +168,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
}),
)
Expand All @@ -178,7 +179,7 @@ describe('Get Project By Tags', () => {
user: {
name: newUser.name,
surname: newUser.surname,
avatar_url: null,
avatar_url: defaultUserAvatarUrl,
},
}),
)
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/utils/tests/defaultUserAvatarUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const defaultUserAvatarUrl =
'https://orangeapp-contents-prod.s3.amazonaws.com/avatar1.png'
6 changes: 1 addition & 5 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: [
'src',
'!src/**/*.spec.*',
'!src/utils/create-and-authenticate-user.ts',
],
entry: ['src', '!src/**/*.spec.*', '!src/utils/tests/**'],
})

0 comments on commit e5739e9

Please sign in to comment.