Skip to content

Commit 408be92

Browse files
committed
Add Jest testing framework and initial test cases for issues called out in #181
- Created jest.config.js for Jest configuration. - Updated package.json to include Jest and TypeScript types for Jest. - Added test scripts for running tests and coverage. - Implemented initial unit tests for icalUtils functions and recurring events. - Enhanced README with testing instructions and guidelines for adding new tests. - Fixed bug caused by non-existent .last / .first
1 parent 32cb72b commit 408be92

File tree

10 files changed

+5988
-1202
lines changed

10 files changed

+5988
-1202
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,17 @@ If for some reason you want to install the plugin manually:
139139
4. `npm run dev` will watch for changes and build the plugin to `dist/main.js`.
140140
5. copy the `dist/main.js` (or `dist/main-debug.js` if you want the un-minified version) to your Obdisian vault plugin folder (`cp dist/main.js <vault>/.obsidian/plugins/ics/main.js`).
141141
6. Reload the vault or use the [Hot Reload Plugin](https://github.com/pjeby/hot-reload).
142+
143+
### Testing
144+
145+
The plugin includes a test harness for recurring events and timezone handling to prevent regressions:
146+
147+
```bash
148+
# Run all tests
149+
npm test
150+
151+
# Run tests in watch mode (automatically re-runs when files change)
152+
npm run test:watch
153+
```
154+
155+
See `tests/README.md` for information about how to add new tests.

jest.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/src', '<rootDir>/tests'],
5+
testMatch: [
6+
'**/__tests__/**/*.ts',
7+
'**/?(*.)+(spec|test).ts'
8+
],
9+
transform: {
10+
'^.+\\.ts$': 'ts-jest',
11+
},
12+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
13+
collectCoverageFrom: [
14+
'src/**/*.ts',
15+
'!src/**/*.d.ts',
16+
],
17+
setupFilesAfterEnv: ['<rootDir>/tests/setup.ts']
18+
};

0 commit comments

Comments
 (0)