File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- module . exports = {
2- testEnvironment : 'node' ,
3- verbose : true ,
4- collectCoverage : true ,
5- coverageDirectory : 'coverage' ,
6- testPathIgnorePatterns : [ '/node_modules/' ] ,
7- coveragePathIgnorePatterns : [ '/node_modules/' , '/tests/' ] ,
8- coverageThreshold : {
9- global : {
10- branches : 70 ,
11- functions : 80 ,
12- lines : 80 ,
13- statements : 80
14- }
15- }
16- } ;
17-
1+ module . exports = {
2+ testEnvironment : 'node' ,
3+ verbose : true ,
4+ collectCoverage : true ,
5+ coverageDirectory : 'coverage' ,
6+ testPathIgnorePatterns : [ '/node_modules/' ] ,
7+ coveragePathIgnorePatterns : [ '/node_modules/' , '/tests/' ] ,
8+ roots : [ '<rootDir>' , '<rootDir>/test' ] ,
9+ coverageThreshold : {
10+ global : {
11+ branches : 70 ,
12+ functions : 80 ,
13+ lines : 80 ,
14+ statements : 80
15+ }
16+ }
17+ } ;
Original file line number Diff line number Diff line change 1+ const mongoose = require ( 'mongoose' ) ;
2+ const Task = require ( '../models/task' ) ;
3+
4+ describe ( 'Task Model Validation' , ( ) => {
5+ it ( 'should fail validation for past dueDate' , async ( ) => {
6+ const pastDate = new Date ( Date . now ( ) - 24 * 60 * 60 * 1000 ) ; // yesterday
7+ const task = new Task ( { title : 'Past Due Task' , dueDate : pastDate } ) ;
8+
9+ try {
10+ await task . validate ( ) ;
11+ // If validate does not throw, force fail
12+ throw new Error ( 'Validation should have failed for past dueDate' ) ;
13+ } catch ( err ) {
14+ expect ( err ) . toBeInstanceOf ( mongoose . Error . ValidationError ) ;
15+ expect ( err . errors . dueDate ) . toBeDefined ( ) ;
16+ }
17+ } ) ;
18+ } ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments