-
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
…-all-nodes #12-getAllNodes
- Loading branch information
Showing
3 changed files
with
28 additions
and
0 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,11 @@ | ||
import prisma from '../prisma/prisma-client'; | ||
import { ResponseFunction } from '../utils/message-maps.utils'; | ||
|
||
/** | ||
* CRUD operation to get all systems with ResponseFunction type | ||
* @returns Promise<string> contianing all the nodes in the db | ||
*/ | ||
export const getAllNodes: ResponseFunction = async () => { | ||
const data = await prisma.node.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 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 { getAllNodes } from '../src/services/nodes.services'; | ||
|
||
describe('Node', () => { | ||
test('Get All Nodes Works', async () => { | ||
const expected = []; | ||
const result = await getAllNodes(); | ||
|
||
// 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); | ||
}); | ||
}); |