diff --git a/__tests__/unit/models/platform.model.test.ts b/__tests__/unit/models/platform.model.test.ts index 877378a..36e2b0c 100644 --- a/__tests__/unit/models/platform.model.test.ts +++ b/__tests__/unit/models/platform.model.test.ts @@ -23,70 +23,5 @@ describe('Platform model', () => { test('should correctly validate a valid platform', async () => { await expect(new Platform(platform).validate()).resolves.toBeUndefined(); }); - - // describe('Middlewares', () => { - // test('Pre Remove: should clean up when platform is deleted', async () => { - // const user = new User({ discordId: 'discordId' }); - // await user.save(); - - // const community = new Community({ users: [user._id], name: 'community' }); - // await community.save(); - - // const platform = new Platform({ name: 'platform', community: community._id }); - // await platform.save(); - - // const module = new Module({ - // name: 'hivemind', - // community: community._id, - // options: { platforms: [{ platform: platform._id }, { platform: new Types.ObjectId() }] }, - // }); - // await module.save(); - - // let communityDoc = await Community.findById(community.id); - // if (communityDoc?.platforms) { - // const idAsString = platform.id.toHexString ? platform.id.toHexString() : platform.id; - // expect(communityDoc.platforms[0].toHexString()).toBe(idAsString); - // } - // await platform.remove(); - // communityDoc = await Community.findById(community.id); - // expect(communityDoc?.platforms).toEqual([]); - // expect(communityDoc?.roles).toEqual([]); - - // const platformDoc = await Platform.findById(platform._id); - // expect(platformDoc).toBe(null); - - // const moduleDoc = await Module.findById(module._id); - // expect(moduleDoc?.options?.platforms.length).toBe(1); - // }); - - // test('Post Save: should add platformId to the community and admin role for the creator of community', async () => { - // const user = new User({ discordId: 'discordId' }); - // await user.save(); - - // const community = new Community({ users: [user._id], name: 'community' }); - // await community.save(); - // user.communities?.push(community._id); - - // const platform = new Platform({ name: 'platform', community: community._id }); - // await platform.save(); - // const communityDoc = await Community.findById(community.id); - // if (communityDoc?.platforms && communityDoc?.roles) { - // const idAsString = platform.id.toHexString ? platform.id.toHexString() : platform.id; - // expect(communityDoc.platforms[0].toHexString()).toBe(idAsString); - // expect(JSON.parse(JSON.stringify(communityDoc.roles))).toEqual([ - // { - // _id: expect.anything(), - // roleType: 'admin', - // source: { - // platform: 'discord', - // identifierType: 'member', - // identifierValues: [user.discordId], - // platformId: platform._id.toHexString(), - // }, - // }, - // ]); - // } - // }); - // }); }); }); diff --git a/__tests__/utils/setupTestDB.ts b/__tests__/utils/setupTestDB.ts index 840c340..394512d 100644 --- a/__tests__/utils/setupTestDB.ts +++ b/__tests__/utils/setupTestDB.ts @@ -1,21 +1,21 @@ -import mongoose from 'mongoose'; -import config from '../../src/config'; +// import mongoose from 'mongoose'; +// import config from '../../src/config'; -const setupTestDB = () => { - beforeAll(async () => { - mongoose.set('strictQuery', false); - await mongoose.connect(config.mongoose.serverURL); - }); +// const setupTestDB = () => { +// beforeAll(async () => { +// mongoose.set('strictQuery', false); +// await mongoose.connect(config.mongoose.serverURL); +// }); - beforeEach(async () => { - await Promise.all( - Object.values(mongoose.connection.collections).map(async (collection) => collection.deleteMany({})), - ); - }); +// beforeEach(async () => { +// await Promise.all( +// Object.values(mongoose.connection.collections).map(async (collection) => collection.deleteMany({})), +// ); +// }); - afterAll(async () => { - await mongoose.disconnect(); - }); -}; +// afterAll(async () => { +// await mongoose.disconnect(); +// }); +// }; -export default setupTestDB; +// export default setupTestDB;