forked from Progyssey/Calmerge
Compare commits
No commits in common. "199a74a5d47c69baeda59499810cb5d0959709fc" and "227ec8a211d396c37d50f1fd99897e3fea939938" have entirely different histories.
199a74a5d4
...
227ec8a211
5 changed files with 23 additions and 10 deletions
|
@ -2,13 +2,13 @@ import express from 'express';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import routes from './routes.js';
|
import routes from './routes.js';
|
||||||
|
|
||||||
console.log(`Starting server in ${process.cwd()}`);
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
|
||||||
// Serve static files from the 'public' directory
|
// Serve static files from the 'public' directory
|
||||||
app.use(express.static(path.join(process.cwd(), 'public')));
|
app.use(express.static(path.join(process.cwd(), 'public')));
|
||||||
app.use('/', routes);
|
app.use('/', routes);
|
||||||
|
|
||||||
|
|
||||||
export default app;
|
export default app;
|
|
@ -1,6 +1,8 @@
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
|
import express from 'express';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import { jest } from '@jest/globals';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
// ESM equivalent of __dirname
|
// ESM equivalent of __dirname
|
||||||
|
@ -13,12 +15,15 @@ const EXPECTED_OUTPUTS_DIR = path.join(__dirname, 'expected_outputs');
|
||||||
|
|
||||||
let server;
|
let server;
|
||||||
process.chdir(__dirname)
|
process.chdir(__dirname)
|
||||||
const app = await import('../src/server');
|
// console.log(process.cwd());
|
||||||
|
import app from '../src/server.js';
|
||||||
|
|
||||||
|
const normalizeLineEndings = (str) => str.replace(/\r\n/g, '\r\n').trimEnd(); // Normalize to CRLF
|
||||||
|
|
||||||
describe('Calendar Merging API', () => {
|
describe('Calendar Merging API', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Start the server
|
// Start the server
|
||||||
server = app.default.listen(0);
|
server = app.listen(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -61,8 +66,12 @@ describe('Calendar Merging API', () => {
|
||||||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
|
|
||||||
|
// Normalize line endings
|
||||||
|
const normalizedActual = normalizeLineEndings(actualOutput);
|
||||||
|
const normalizedExpected = normalizeLineEndings(expectedOutput);
|
||||||
|
|
||||||
//compare
|
//compare
|
||||||
expect(actualOutput).toBe(expectedOutput);
|
expect(normalizedActual).toBe(normalizedExpected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Preserve google calendar', async () => {
|
test('Preserve google calendar', async () => {
|
||||||
|
@ -89,8 +98,12 @@ describe('Calendar Merging API', () => {
|
||||||
const expectedOutput = fs.readFileSync(input, 'utf8');
|
const expectedOutput = fs.readFileSync(input, 'utf8');
|
||||||
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
const actualOutput = fs.readFileSync(filePath, 'utf8');
|
||||||
|
|
||||||
|
// Normalize line endings
|
||||||
|
const normalizedActual = normalizeLineEndings(actualOutput);
|
||||||
|
const normalizedExpected = normalizeLineEndings(expectedOutput);
|
||||||
|
|
||||||
//compare
|
//compare
|
||||||
expect(actualOutput).toBe(expectedOutput);
|
expect(normalizedActual).toBe(normalizedExpected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue