From f88fe94b5852187796b29e42bd60c154a4472502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20Huerta=20Arrabal?= Date: Thu, 17 Oct 2024 23:02:56 +0200 Subject: [PATCH] chore: Remove unecesary hydrated element --- CHANGELOG | 6 ++++++ test/models/assistants.test.ts | 5 +---- test/models/conversation-chunks.test.ts | 9 +++------ test/models/conversations.test.ts | 9 +++------ test/models/event.test.ts | 6 ++---- test/models/game-score.test.ts | 11 ++++------- test/models/game.test.ts | 5 +---- test/models/player-reward.test.ts | 13 +++++-------- test/models/player-session.test.ts | 6 ++---- test/models/player.test.ts | 4 +--- test/models/reward.test.ts | 15 +++++---------- test/models/wallets.test.ts | 6 ++---- 12 files changed, 35 insertions(+), 60 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ac1502b..ccbb415 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [6.0.1] - 2024-10-17 + +### Changed + +- Remove unecesary hydrated element + ## [6.0.0] - 2024-10-14 ### Added diff --git a/test/models/assistants.test.ts b/test/models/assistants.test.ts index 494f8af..4df2d8c 100644 --- a/test/models/assistants.test.ts +++ b/test/models/assistants.test.ts @@ -1,9 +1,6 @@ -import { HydratedDocument } from 'mongoose'; - import { AssistantDocument } from '../../src/types'; import { mongoose, AssistantModel } from '../../src'; import createAssistant from '../helpers/create-assistant'; -import { AssistantAttributes } from '../../src/interfaces'; const testDatabase = require('../test-db')(mongoose); @@ -13,7 +10,7 @@ describe('Assistant', () => { afterAll(() => testDatabase.close()); describe('when create a new assistant', () => { - let assistantObject: HydratedDocument; + let assistantObject: AssistantDocument; beforeAll(async () => { assistantObject = await createAssistant(); diff --git a/test/models/conversation-chunks.test.ts b/test/models/conversation-chunks.test.ts index 36f5395..e87885f 100644 --- a/test/models/conversation-chunks.test.ts +++ b/test/models/conversation-chunks.test.ts @@ -1,7 +1,4 @@ -import { HydratedDocument } from 'mongoose'; - -import { ConversationAttributes, ConversationChunkAttributes } from '../../src/interfaces'; -import { ConversationChunkDocument } from '../../src/types'; +import { ConversationChunkDocument, ConversationDocument } from '../../src/types'; import createConversation from '../helpers/create-conversation'; import createConversationChunk from '../helpers/create-conversation-chunk'; import { mongoose, ConversationChunkModel, ConversationModel } from '../../src'; @@ -14,8 +11,8 @@ describe('ConversationChunks', () => { afterAll(() => testDatabase.close()); describe('when create a new conversation', () => { - let conversationObject: HydratedDocument; - let conversationChunkObject: HydratedDocument; + let conversationObject: ConversationDocument; + let conversationChunkObject: ConversationChunkDocument; beforeAll(async () => { conversationObject = await createConversation({ diff --git a/test/models/conversations.test.ts b/test/models/conversations.test.ts index 14f9f5c..8b1b0a3 100644 --- a/test/models/conversations.test.ts +++ b/test/models/conversations.test.ts @@ -1,10 +1,7 @@ -import { HydratedDocument } from 'mongoose'; - import createPlayer from '../helpers/create-player'; -import { ConversationDocument } from '../../src/types'; +import { ConversationDocument, PlayerDocument } from '../../src/types'; import { mongoose, ConversationModel, PlayerModel } from '../../src'; import createConversation from '../helpers/create-conversation'; -import { ConversationAttributes, PlayerAttributes } from '../../src/interfaces'; const testDatabase = require('../test-db')(mongoose); @@ -22,8 +19,8 @@ describe('Conversation', () => { }); describe('when create a new conversation', () => { - let playerObject: HydratedDocument; - let conversationObject: HydratedDocument; + let playerObject: PlayerDocument; + let conversationObject: ConversationDocument; beforeAll(async () => { playerObject = await createPlayer(); diff --git a/test/models/event.test.ts b/test/models/event.test.ts index 0b7947a..25aa904 100644 --- a/test/models/event.test.ts +++ b/test/models/event.test.ts @@ -1,5 +1,3 @@ -import { HydratedDocument } from 'mongoose'; - import createEvent from '../helpers/create-event'; import createPlayer from '../helpers/create-player'; import { EventModel, PlayerModel, mongoose } from '../../src'; @@ -13,8 +11,8 @@ describe('Events', () => { afterAll(() => testDatabase.close()); describe('when creating a new player', () => { - let eventObject: HydratedDocument; - let playerObject: HydratedDocument; + let eventObject: EventDocument; + let playerObject: PlayerDocument; beforeAll(async () => { playerObject = await createPlayer(); diff --git a/test/models/game-score.test.ts b/test/models/game-score.test.ts index f97e31a..faf4b78 100644 --- a/test/models/game-score.test.ts +++ b/test/models/game-score.test.ts @@ -1,11 +1,8 @@ -import { HydratedDocument } from 'mongoose'; - import createGame from '../helpers/create-game'; import createPlayer from '../helpers/create-player'; -import { GameScoreDocument } from '../../src/types'; +import { GameDocument, GameScoreDocument, PlayerDocument } from '../../src/types'; import createGameScore from '../helpers/create-game-score'; import { mongoose, GameScoreModel, PlayerModel, GameModel } from '../../src'; -import { GameAttributes, PlayerAttributes, GameScoreAttributes } from '../../src/interfaces'; const testDatabase = require('../test-db')(mongoose); @@ -15,9 +12,9 @@ describe('GameScore', () => { afterAll(() => testDatabase.close()); describe('when creating a new collect coins game', () => { - let userObject: HydratedDocument; - let gameObject: HydratedDocument; - let gameScoreObject: HydratedDocument; + let userObject: PlayerDocument; + let gameObject: GameDocument; + let gameScoreObject: GameScoreDocument; beforeAll(async () => { [gameObject, userObject] = await Promise.all([createGame(), createPlayer()]); diff --git a/test/models/game.test.ts b/test/models/game.test.ts index fa1d053..6943d36 100644 --- a/test/models/game.test.ts +++ b/test/models/game.test.ts @@ -1,9 +1,6 @@ -import { HydratedDocument } from 'mongoose'; - import createGame from '../helpers/create-game'; import { GameDocument } from '../../src/types'; import { mongoose, GameModel } from '../../src'; -import { GameAttributes } from '../../src/interfaces'; const testDatabase = require('../test-db')(mongoose); @@ -13,7 +10,7 @@ describe('Game', () => { afterAll(() => testDatabase.close()); describe('when creating a new collect coins game', () => { - let gameObject: HydratedDocument; + let gameObject: GameDocument; beforeAll(async () => { gameObject = await createGame(); diff --git a/test/models/player-reward.test.ts b/test/models/player-reward.test.ts index c3ad38b..d0daa6d 100644 --- a/test/models/player-reward.test.ts +++ b/test/models/player-reward.test.ts @@ -1,7 +1,4 @@ -import { HydratedDocument } from 'mongoose'; - -import { RewardAttributes, PlayerRewardAttributes, PlayerAttributes } from '../../src/interfaces'; -import { PlayerRewardDocument } from '../../src/types'; +import { PlayerDocument, PlayerRewardDocument, RewardDocument } from '../../src/types'; import createReward from '../helpers/create-reward'; import createPlayer from '../helpers/create-player'; import rewardTypes from '../../src/constants/reward-types'; @@ -16,9 +13,9 @@ describe('PlayerReward', () => { afterAll(() => testDatabase.close()); describe('when create a new player reward', () => { - let playerObject: HydratedDocument; - let rewardObject: HydratedDocument; - let playerRewardObject: HydratedDocument; + let playerObject: PlayerDocument; + let rewardObject: RewardDocument; + let playerRewardObject: PlayerRewardDocument; beforeAll(async () => { playerObject = await createPlayer(); @@ -47,7 +44,7 @@ describe('PlayerReward', () => { expect(playerRewardDocument.createdAt).toBeDefined(); expect(playerRewardDocument.updatedAt).toBeDefined(); expect(playerRewardDocument.playerId).toBeDefined(); - expect(playerRewardDocument.rewardId.toString()).toBe(rewardObject._id.toString()); + expect(playerRewardDocument.rewardId.toString()).toBe(rewardObject._id?.toString()); }); }); }); diff --git a/test/models/player-session.test.ts b/test/models/player-session.test.ts index 560620b..a97f9ba 100644 --- a/test/models/player-session.test.ts +++ b/test/models/player-session.test.ts @@ -1,5 +1,3 @@ -import { HydratedDocument } from 'mongoose'; - import createPlayer from '../helpers/create-player'; import createPlayerSession from '../helpers/create-player-session'; import { PlayerSessionModel, PlayerModel, mongoose } from '../../src'; @@ -13,8 +11,8 @@ describe('player-session', () => { afterAll(() => testDatabase.close()); describe('when creating a new player', () => { - let playerObject: HydratedDocument; - let playerSessionObject: HydratedDocument; + let playerObject: PlayerDocument; + let playerSessionObject: PlayerSessionDocument; beforeAll(async () => { playerObject = await createPlayer(); diff --git a/test/models/player.test.ts b/test/models/player.test.ts index 8fbc1db..f7812dd 100644 --- a/test/models/player.test.ts +++ b/test/models/player.test.ts @@ -1,5 +1,3 @@ -import { HydratedDocument } from 'mongoose'; - import { PlayerDocument } from '../../src/types'; import { PlayerModel, mongoose } from '../../src'; import createPlayer from '../helpers/create-player'; @@ -12,7 +10,7 @@ describe('Players', () => { afterAll(() => testDatabase.close()); describe('when creating a new player', () => { - let playerObject: HydratedDocument; + let playerObject: PlayerDocument; beforeAll(async () => { playerObject = await createPlayer(); diff --git a/test/models/reward.test.ts b/test/models/reward.test.ts index 5a40926..b393829 100644 --- a/test/models/reward.test.ts +++ b/test/models/reward.test.ts @@ -2,12 +2,7 @@ import createReward from '../helpers/create-reward'; import { mongoose, RewardModel } from '../../src'; import RewardTypes from '../../src/constants/reward-types'; -import { - DigitalAssetRewardAttributes, - InGameRewardAttributes, - RewardAttributes, -} from '../../src/interfaces'; -import { HydratedDocument } from 'mongoose'; +import { DigitalAssetRewardDocument, InGameRewardDocument, RewardDocument } from '../../src/types'; const testDatabase = require('../test-db')(mongoose); @@ -17,7 +12,7 @@ describe('Game', () => { afterAll(() => testDatabase.close()); describe(`Reward with ${RewardTypes.IN_GAME_ITEM}`, () => { - let playerRewardObject: HydratedDocument; + let playerRewardObject: RewardDocument; beforeAll(async () => { playerRewardObject = await createReward(RewardTypes.IN_GAME_ITEM); @@ -26,7 +21,7 @@ describe('Game', () => { afterAll(() => RewardModel.deleteOne({ _id: playerRewardObject._id })); test(`it should contain all the properties for ${RewardTypes.IN_GAME_ITEM}`, async () => { - const RewardDocument = ( + const RewardDocument = ( await RewardModel.findById(playerRewardObject._id) ); @@ -43,7 +38,7 @@ describe('Game', () => { }); describe(`Reward with ${RewardTypes.DIGITAL_ASSET}`, () => { - let playerRewardObject: HydratedDocument; + let playerRewardObject: RewardDocument; beforeAll(async () => { playerRewardObject = await createReward(RewardTypes.DIGITAL_ASSET); @@ -52,7 +47,7 @@ describe('Game', () => { afterAll(() => RewardModel.deleteOne({ _id: playerRewardObject._id })); test(`it should contain all the properties for ${RewardTypes.DIGITAL_ASSET}`, async () => { - const RewardDocument = ( + const RewardDocument = ( await RewardModel.findById(playerRewardObject._id) ); diff --git a/test/models/wallets.test.ts b/test/models/wallets.test.ts index 7100abe..0feb292 100644 --- a/test/models/wallets.test.ts +++ b/test/models/wallets.test.ts @@ -1,5 +1,3 @@ -import { HydratedDocument } from 'mongoose'; - import createWallet from '../helpers/create-wallet'; import createPlayer from '../helpers/create-player'; import { WalletModel, PlayerModel, mongoose } from '../../src'; @@ -13,8 +11,8 @@ describe('Wallets', () => { afterAll(() => testDatabase.close()); describe('when creating a new player', () => { - let playerObject: HydratedDocument; - let walletObject: HydratedDocument; + let playerObject: PlayerDocument; + let walletObject: WalletDocument; beforeAll(async () => { playerObject = await createPlayer();