test (calendar.test.js): Add logging
This commit is contained in:
parent
54d3a35c43
commit
996623b3d7
|
@ -4,15 +4,16 @@ import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import app from './server';
|
import app from './server';
|
||||||
|
|
||||||
const TEST_MERGED_CALENDARS_DIR = path.join(__dirname, 'temp_test_calendar');
|
// Set environment variable for the test directory
|
||||||
const MERGED_CALENDARS_DIR = 'calendar';
|
process.env.TEST_MERGED_CALENDARS_DIR = path.join(__dirname, 'temp_test_calendar');
|
||||||
|
|
||||||
|
const TEST_MERGED_CALENDARS_DIR = process.env.TEST_MERGED_CALENDARS_DIR;
|
||||||
const TEST_CALENDARS_DIR = 'test_calendars';
|
const TEST_CALENDARS_DIR = 'test_calendars';
|
||||||
|
console.log(`Test Merged Calendars Directory: ${TEST_MERGED_CALENDARS_DIR}`);
|
||||||
let server;
|
let server;
|
||||||
|
|
||||||
describe('Calendar Merging API', () => {
|
describe('Calendar Merging API', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Set environment variable for the test directory
|
|
||||||
process.env.TEST_MERGED_CALENDARS_DIR = TEST_MERGED_CALENDARS_DIR;
|
|
||||||
// Start the server
|
// Start the server
|
||||||
server = app.listen(0);
|
server = app.listen(0);
|
||||||
// Ensure the test merged calendars directory exists
|
// Ensure the test merged calendars directory exists
|
||||||
|
@ -22,8 +23,10 @@ describe('Calendar Merging API', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
// Clean up the merged calendars directory after tests
|
// // Clean up the merged calendars directory after tests
|
||||||
fs.rmSync(TEST_MERGED_CALENDARS_DIR, { recursive: true, force: true });
|
// if (fs.existsSync(TEST_MERGED_CALENDARS_DIR)) {
|
||||||
|
// fs.rmSync(TEST_MERGED_CALENDARS_DIR, { recursive: true, force: true });
|
||||||
|
// }
|
||||||
|
|
||||||
// Close the server
|
// Close the server
|
||||||
await new Promise(resolve => server.close(resolve));
|
await new Promise(resolve => server.close(resolve));
|
||||||
|
@ -104,7 +107,7 @@ describe('Calendar Merging API', () => {
|
||||||
expect(response.body.url).toMatch(/calendar\/No_Prefix_Calendar/);
|
expect(response.body.url).toMatch(/calendar\/No_Prefix_Calendar/);
|
||||||
|
|
||||||
// Check if the file was created in the test directory
|
// Check if the file was created in the test directory
|
||||||
const filePath = path.join(MTEST_MERGED_CALENDARS_DIR, 'No_Prefix_Calendar.ics');
|
const filePath = path.join(TEST_MERGED_CALENDARS_DIR, 'No_Prefix_Calendar.ics');
|
||||||
expect(fs.existsSync(filePath)).toBe(true);
|
expect(fs.existsSync(filePath)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
const MERGED_CALENDARS_DIR = process.env.TEST_MERGED_CALENDARS_DIR || 'calendar';
|
const MERGED_CALENDARS_DIR = process.env.TEST_MERGED_CALENDARS_DIR || 'calendar';
|
||||||
|
console.log(`Merged calendars directory: ${MERGED_CALENDARS_DIR}`);
|
||||||
|
|
||||||
|
|
||||||
// Ensure the merged calendars directory exists
|
// Ensure the merged calendars directory exists
|
||||||
|
|
Loading…
Reference in New Issue