I am trying to create a function that adds data into a posgreSQL database using javascript the TDD way but then I find it difficult to write a test that checks if the function has really inserted data into the database here is my code
require("dotenv").config();
const Pool = require("pg").Pool;
const pool = new Pool({
user: process.env.User,
host: process.env.HOST,
database: process.env.DB,
password: process.env.PASSWORD,
port: process.env.PORT,
});
const addNewVisitor = (name, age, date, time, assistor, comment) => {
pool.query(
`INSERT INTO Visiters(visitorName,visitorAge,dateOfVisit,timeOfVisit,nameOfThePersonWhoAssistedTheVisitor,comments)VALUES($1,$2,$3,$4,$5,$6)`,
[name, age, date, time, assistor, comment],
(error) => {
if (error) {
console.log(error);
}
console.log("Visitor added");
}
);
};