diff --git a/jest.config.js b/jest.config.js index e5d2c18..6243b7b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,17 +1,17 @@ -module.exports = { - testEnvironment: 'node', - verbose: true, - collectCoverage: true, - coverageDirectory: 'coverage', - testPathIgnorePatterns: ['/node_modules/'], - coveragePathIgnorePatterns: ['/node_modules/', '/tests/'], - coverageThreshold: { - global: { - branches: 70, - functions: 80, - lines: 80, - statements: 80 - } - } - }; - \ No newline at end of file +module.exports = { + testEnvironment: 'node', + verbose: true, + collectCoverage: true, + coverageDirectory: 'coverage', + testPathIgnorePatterns: ['/node_modules/'], + coveragePathIgnorePatterns: ['/node_modules/', '/tests/'], + roots: ['', '/test'], + coverageThreshold: { + global: { + branches: 70, + functions: 80, + lines: 80, + statements: 80 + } + } +}; diff --git a/test/taskModel.test.js b/test/taskModel.test.js new file mode 100644 index 0000000..99d6377 --- /dev/null +++ b/test/taskModel.test.js @@ -0,0 +1,18 @@ +const mongoose = require('mongoose'); +const Task = require('../models/task'); + +describe('Task Model Validation', () => { + it('should fail validation for past dueDate', async () => { + const pastDate = new Date(Date.now() - 24 * 60 * 60 * 1000); // yesterday + const task = new Task({ title: 'Past Due Task', dueDate: pastDate }); + + try { + await task.validate(); + // If validate does not throw, force fail + throw new Error('Validation should have failed for past dueDate'); + } catch (err) { + expect(err).toBeInstanceOf(mongoose.Error.ValidationError); + expect(err.errors.dueDate).toBeDefined(); + } + }); +}); diff --git a/test_dir/test_file.txt b/test_dir/test_file.txt deleted file mode 100644 index 0902c22..0000000 --- a/test_dir/test_file.txt +++ /dev/null @@ -1 +0,0 @@ -Testing file creation to diagnose error cause. \ No newline at end of file