forked from ryanmwangi/CalMerger
Compare commits
2 commits
227ec8a211
...
199a74a5d4
Author | SHA1 | Date | |
---|---|---|---|
|
199a74a5d4 | ||
|
d05c29332c |
5 changed files with 10 additions and 23 deletions
|
@ -2,13 +2,13 @@ import express from 'express';
|
|||
import path from 'path';
|
||||
import routes from './routes.js';
|
||||
|
||||
console.log(`Starting server in ${process.cwd()}`);
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
||||
|
||||
// Serve static files from the 'public' directory
|
||||
app.use(express.static(path.join(process.cwd(), 'public')));
|
||||
app.use('/', routes);
|
||||
|
||||
|
||||
export default app;
|
||||
export default app;
|
|
@ -1,8 +1,6 @@
|
|||
import request from 'supertest';
|
||||
import express from 'express';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { jest } from '@jest/globals';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
// ESM equivalent of __dirname
|
||||
|
@ -15,15 +13,12 @@ const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
|
|||
|
||||
let server;
|
||||
process.chdir(__dirname)
|
||||
// console.log(process.cwd());
|
||||
import app from '../src/server.js';
|
||||
|
||||
const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF
|
||||
const app = await import('../src/server');
|
||||
|
||||
describe('Calendar Merging API', () => {
|
||||
beforeAll(async () => {
|
||||
// Start the server
|
||||
server = app.listen(0);
|
||||
server = app.default.listen(0);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -66,12 +61,8 @@ describe('Calendar Merging API', () => {
|
|||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// Normalize line endings
|
||||
const normalizedActual = normalizeLineEndings(actualOutput);
|
||||
const normalizedExpected = normalizeLineEndings(expectedOutput);
|
||||
|
||||
//compare
|
||||
expect(normalizedActual).toBe(normalizedExpected);
|
||||
expect(actualOutput).toBe(expectedOutput);
|
||||
});
|
||||
|
||||
test('Preserve google calendar', async () => {
|
||||
|
@ -98,12 +89,8 @@ describe('Calendar Merging API', () => {
|
|||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// Normalize line endings
|
||||
const normalizedActual = normalizeLineEndings(actualOutput);
|
||||
const normalizedExpected = normalizeLineEndings(expectedOutput);
|
||||
|
||||
//compare
|
||||
expect(normalizedActual).toBe(normalizedExpected);
|
||||
expect(actualOutput).toBe(expectedOutput);
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -13,4 +13,4 @@ UID:6tbrvsitniuu72li7kk15gou2b@google.com
|
|||
SUMMARY:progodessey
|
||||
SEQUENCE:0
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
END:VCALENDAR
|
|
@ -41,4 +41,4 @@ STATUS:CONFIRMED
|
|||
SUMMARY:do
|
||||
TRANSP:OPAQUE
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
END:VCALENDAR
|
|
@ -30,4 +30,4 @@ RRULE:FREQ=WEEKLY;BYDAY=WE
|
|||
SUMMARY:JR Weekly Check-In
|
||||
SEQUENCE:0
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
||||
END:VCALENDAR
|
Loading…
Add table
Reference in a new issue