-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#9 - CRUD get all data types
- Loading branch information
Showing
4 changed files
with
29 additions
and
8 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,12 @@ | ||
import prisma from '../prisma/prisma-client'; | ||
import { ResponseFunction } from '../utils/message-maps.utils'; | ||
|
||
/** | ||
* CRUD operation to get all dataTypes | ||
* @returns string containing all the dataTypes | ||
*/ | ||
|
||
export const getAllDataTypes: ResponseFunction = async () => { | ||
const data = await prisma.dataType.findMany(); | ||
return JSON.stringify(data); | ||
}; |
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 was deleted.
Oops, something went wrong.
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,15 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import { getAllDataTypes } from '../src/services/dataTypes.services'; | ||
|
||
describe('Data Type', () => { | ||
test('Get All Data Types Works', async () => { | ||
const expected = []; | ||
const result = await getAllDataTypes(); | ||
|
||
// Parse result to a JavaScript object from the JSON string | ||
const parsedResult = JSON.parse(result); | ||
|
||
// Use toEqual to compare parsedResult with the expected array | ||
expect(parsedResult).toEqual(expected); | ||
}); | ||
}); |