-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'add--project-frontend-api-with-test-and-fix-backend-pro…
…ject' of https://github.com/Sma1lboy/GeneratorAI into add--project-frontend-api-with-test-and-fix-backend-project
- Loading branch information
Showing
5 changed files
with
357 additions
and
84 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; | ||
|
||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
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
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 |
---|---|---|
@@ -1,40 +1,45 @@ | ||
import { getUserProjects, getProjectDetails, deleteProject, upsertProject, removePackageFromProject } from '../app/api/project/route'; | ||
import { | ||
getUserProjects, | ||
getProjectDetails, | ||
deleteProject, | ||
upsertProject, | ||
removePackageFromProject, | ||
} from '../app/api/project/route'; | ||
|
||
describe('Project API', () => { | ||
let projectId: string; | ||
let packageId: string; | ||
|
||
it('should upsert a project', async () => { | ||
const upsertProjectInput = { | ||
projectName: 'Test Project', | ||
projectPackages: ['Package 1', 'Package 2'], | ||
}; | ||
const project = await upsertProject(upsertProjectInput); | ||
expect(project).toHaveProperty('id'); | ||
projectId = project.id; | ||
console.log('Project id is: ' + projectId) | ||
packageId = project.projectPackages[0].id; | ||
}); | ||
|
||
it('should get user projects', async () => { | ||
const projects = await getUserProjects(); | ||
expect(Array.isArray(projects)).toBe(true); | ||
expect(projects.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it('should get project details', async () => { | ||
const projectDetails = await getProjectDetails(projectId); | ||
expect(projectDetails).toHaveProperty('id', projectId); | ||
}); | ||
|
||
it('should remove a package from project', async () => { | ||
const removed = await removePackageFromProject(projectId, packageId); | ||
expect(removed).toBe(true); | ||
}); | ||
|
||
it('should delete a project', async () => { | ||
const deleted = await deleteProject(projectId); | ||
expect(deleted).toBe(true); | ||
}); | ||
let projectId: string; | ||
let packageId: string; | ||
|
||
it('should upsert a project', async () => { | ||
const upsertProjectInput = { | ||
projectName: 'Test Project', | ||
projectPackages: ['Package 1', 'Package 2'], | ||
}; | ||
const project = await upsertProject(upsertProjectInput); | ||
expect(project).toHaveProperty('id'); | ||
projectId = project.id; | ||
console.log('Project id is: ' + projectId); | ||
packageId = project.projectPackages[0].id; | ||
}); | ||
|
||
it('should get user projects', async () => { | ||
const projects = await getUserProjects(); | ||
expect(Array.isArray(projects)).toBe(true); | ||
expect(projects.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it('should get project details', async () => { | ||
const projectDetails = await getProjectDetails(projectId); | ||
expect(projectDetails).toHaveProperty('id', projectId); | ||
}); | ||
|
||
it('should remove a package from project', async () => { | ||
const removed = await removePackageFromProject(projectId, packageId); | ||
expect(removed).toBe(true); | ||
}); | ||
|
||
it('should delete a project', async () => { | ||
const deleted = await deleteProject(projectId); | ||
expect(deleted).toBe(true); | ||
}); | ||
}); |
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
Oops, something went wrong.