• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ULL-ESIT-INF-DSI-2526 / prct12_practica12 / 25431225842

06 May 2026 10:56AM UTC coverage: 60.317%. First build
25431225842

push

github

PabloPH05
Practica

9 of 20 branches covered (45.0%)

Branch coverage included in aggregate %.

29 of 43 new or added lines in 5 files covered. (67.44%)

29 of 43 relevant lines covered (67.44%)

2.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/data/gameSchema.ts
1
import { Schema, model } from 'mongoose';
2
import { intGame } from './gameInterface.js';
3

4
// export interface intGame {
5
//     title: string,
6
//     developer: string,
7
//     publisher: string,
8
//     genre: Genre[],
9
//     platform: Platorm[],
10
//     releaseDate: Date,
11
//     price: number,
12
//     score?: number,
13
//     multiplayer: boolean,
14
//     dlcs: DLC[]
15
// }
16

17
const gameSchema = new Schema({
3✔
18
  title: {
19
    type: String,
20
    required: true,
21
    unique: true,
22
  },
23
  developer: {
24
    type: String,
25
    required: true,
26
  },
27
  publisher: {
28
    type: String,
29
    required: true,
30
  },
31
  genre: {
32
    type: [
33
      {
34
        type: String,
35
        trim: true,
36
      },
37
    ],
38
    required: true,
39
    validate: {
40
      validator: (value: string[]) => {
41
        return value.length > 0;
15✔
42
      },
43
      message: 'El array debe contener por lo menos un elemento',
44
    },
45
    enum: [
46
      'Action',
47
      'RPG',
48
      'Strategy',
49
      'Puzzle',
50
      'Sports',
51
      'Simulation',
52
      'Horror',
53
      'Adventure',
54
    ],
55
  },
56
  platform: {
57
    type: [
58
      {
59
        type: String,
60
        trim: true,
61
      },
62
    ],
63
    required: true,
64
    validate: {
65
      validator: (value: string[]) => {
66
        return value.length > 0;
15✔
67
      },
68
      message: 'El array debe contener por lo menos un elemento',
69
    },
70
    enum: ['Pc', 'PS5', 'Xbox', 'Switch', 'Mobile'],
71
  },
72
  releaseDate: {
73
    type: Date,
74
    required: true,
75
  },
76
  price: {
77
    type: Number,
78
    validate: {
79
      validator: (value: number) => {
80
        return value >= 0;
15✔
81
      },
82
      message: 'El precio debe no ser negativo',
83
    },
84
  },
85
  score: {
86
    type: Number,
87
    validate: {
88
      validator: (value: number) => {
89
        return value >= 0 && value <= 100;
15✔
90
      },
91
      message: 'La puntuaciรณn debe estar entre 0 y 100',
92
    },
93
  },
94
  multiplayer: {
95
    type: Boolean,
96
    default: false,
97
  },
98
  dlcs: {
99
    type: [
100
      {
101
        name: {
102
          type: String,
103
          required: true,
104
        },
105
        priceEur: {
106
          type: Number,
107
          validate: {
108
            validator: (value: number) => {
NEW
109
              return value >= 0;
×
110
            },
111
            message: 'El precio del DLC debe no ser negativo',
112
          },
113
        },
114
      },
115
    ],
116
  },
117
});
118

119
export const Game = model<intGame>('Game', gameSchema);
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc