From 06086b2371cd8b246aa39485774f9335cf3357df Mon Sep 17 00:00:00 2001 From: mansourkira Date: Sun, 17 Mar 2024 21:36:10 +0100 Subject: [PATCH] chore : remove old unit tests --- test/aws-s3.spec.js | 30 ---------------- test/db.spec.js | 64 ---------------------------------- test/resolver/User.resolver.js | 25 ------------- test/schema.spec.js | 23 ------------ test/schema/User.type.graphql | 23 ------------ 5 files changed, 165 deletions(-) delete mode 100644 test/aws-s3.spec.js delete mode 100644 test/db.spec.js delete mode 100644 test/resolver/User.resolver.js delete mode 100644 test/schema.spec.js delete mode 100644 test/schema/User.type.graphql diff --git a/test/aws-s3.spec.js b/test/aws-s3.spec.js deleted file mode 100644 index fd3f137..0000000 --- a/test/aws-s3.spec.js +++ /dev/null @@ -1,30 +0,0 @@ -const AWS = require("aws-sdk"); -const Hajar = require("../src/index").default; - -describe("InitializeS3", () => { - it("creates an instance of the S3 client", () => { - const s3 = "AWS.S3"; - expect(s3).toBe("AWS.S3"); - }); -}); - -/* -@TODO : add test for the S3 after the implementation of the S3 , Access is required -/* -describe("initializeS3", () => { - it("creates an instance of the S3 client", () => { - const s3 = Hajar.S3.InitializeS3(); - expect(s3).toBeInstanceOf(AWS.S3); - }); -}); -*/ -/* describe("UploadImage", () => { - it("uploads a file to S3", async () => { - const s3 = Hajar.S3.InitializeS3(); - const file = new File(["test"], "test.txt", { type: "text/plain" }); - const result = await Hajar.S3.UploadImage(s3, file); - expect(result).toBeTruthy(); - }); -}); */ - -// TODO : add test for the database diff --git a/test/db.spec.js b/test/db.spec.js deleted file mode 100644 index 4f366ab..0000000 --- a/test/db.spec.js +++ /dev/null @@ -1,64 +0,0 @@ -const Hajar = require("../src/index").default; -// Test database part -// The purpose of these tests is to validate that the function correctly sets up a connection to the specified database type. -// The tests cover three scenarios: a successful connection to MongoDB, a successful connection to MySQL, and an unsupported database type. - -/*describe("Database", () => { - it("should return a connected MongoDB instance", async () => { - const type = "MongoDB"; - const options = { - url: `mongodb+srv://${process.env.MONGO_USER}:${process.env.MONGO_PASSWORD}@${process.env.MONGO_DB_HOST}/${process.env.MONGO_DB}?retryWrites=true&w=majority`, - }; - const db = await Hajar.Database.initialize(type, options); - - expect(db.connection.readyState).toBe(1); // connected - - // Check if the connection is successful - //expect(db).toBeTruthy(); - // expect(db.connection.readyState).toBe(1); // connected - });*/ -/* it("should return a connected MySQL instance", async () => { - const options = { - type: "mysql", - url: "mysql://localhost:3306/test-db", - }; - - const db = await Hajar.Database.initialize(options); - - expect(db).toBeTruthy(); - expect(db.state).toBe("connected"); - }); */ - -it("should return null for unsupported database types", async () => { - const options = { - type: "unsupported", - url: "invalid://localhost:1234/test-db", - }; - const db = await Hajar.Database.initialize(options); - expect(db).toBeNull(); -}); - -// Add a new model to the database -/* -describe("addModel", () => { - it("adds a new model to the database", async () => { - const modelName = "TestModel"; - const schema = new mongoose.Schema({ - name: String, - age: Number, - }); - - /* - @TODO: to be redesigned - // @Mansour - // Here we will give modelName and schema to the function - // and it will return a model - // We can use this function to create Schema and resolver for the model - */ -/* - const testModel = Hajar.Database.model(modelName, schema); - expect(testModel.modelName).toBe(modelName); - }); - -}); -*/ diff --git a/test/resolver/User.resolver.js b/test/resolver/User.resolver.js deleted file mode 100644 index ca827a0..0000000 --- a/test/resolver/User.resolver.js +++ /dev/null @@ -1,25 +0,0 @@ - - const User = require('./models/User'); - module.exports = { - Query: { - async getUsers() { - return await User.find(); - }, - async getUser(_, { id }) { - return await User.findById({_id : id}); - } - }, - Mutation: { - async createUser(_, { input }) { - const newUser = new User(input); - return await newUser.save(); - }, - async updateUser(_, { id, input }) { - return await User.findByIdAndUpdate(id, input, { new: true }); - }, - async deleteUser(_, { id }) { - return await User.findByIdAndDelete({_id :id}); - } - } -}; - \ No newline at end of file diff --git a/test/schema.spec.js b/test/schema.spec.js deleted file mode 100644 index d467060..0000000 --- a/test/schema.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -const mongoose = require("mongoose"); -const Hajar = require("../src/index").default; -/* - @Mansour Test Part -*/ -// Test create Schema function -describe("CreateSchema", () => { - it("should create a valid GraphQL schema and the resolver for a Mongoose model", () => { - const User = mongoose.model("User", { - name: String, - email: String, - password: String, - }); - - // This Part will create a schema for the User model - const schema = Hajar.Schema(User); - - expect(schema).toBeDefined(); - // This Part will create a resolver for the same User model - const resolver = Hajar.Resolver(User); - expect(resolver).toBeDefined(); - }); -}); diff --git a/test/schema/User.type.graphql b/test/schema/User.type.graphql deleted file mode 100644 index fb2b28a..0000000 --- a/test/schema/User.type.graphql +++ /dev/null @@ -1,23 +0,0 @@ - - type User { - name: String -email: String -password: String - } - input UserInput { - name: String -email: String -password: String - } - type Query { - getUsers: [User] - getUser(_id : ID): User - - } - type Mutation { - createUser(input: UserInput): User - updateUser(_id: ID, input: UserInput): User - deleteUser(_id: ID): User - } - - \ No newline at end of file