forked from plone/volto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Links containing two @ signs can't be added plone#6448 github- Harshit-7373
- Loading branch information
1 parent
2d47989
commit a237e41
Showing
3 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import request from 'supertest'; | ||
import { createServer } from '../server'; // Path to your server.js file | ||
|
||
describe('POST /schedule-event', () => { | ||
let app; | ||
|
||
beforeAll(async () => { | ||
// Create the app with your server function | ||
const server = await createServer(); | ||
app = server.app; | ||
}); | ||
|
||
it('should remove "@" from request body', async () => { | ||
const response = await request(app) | ||
.post('/schedule-event') | ||
.send({ | ||
startDatetime: '2024-12-25T10:00:00Z', | ||
endDatetime: '2024-12-25T12:00:00Z', | ||
isAllDay: false, | ||
isRecurring: false, | ||
email: 'test@[email protected]', // This contains '@' to be removed | ||
}); | ||
|
||
// Ensure no "@" is present in the email field after sanitization | ||
expect(response.body.event).toBeDefined(); | ||
expect(response.body.message).toBe('Event scheduled successfully.'); | ||
expect(response.body.event.email).not.toContain('@'); // Ensure no @ in the email | ||
}); | ||
|
||
it('should handle "@" in query params correctly', async () => { | ||
const response = await request(app) | ||
.get('/schedule-event?email=test@[email protected]') // This contains '@' to be removed | ||
.send(); | ||
|
||
// Ensure no "@" is present in the query parameter after sanitization | ||
expect(response.status).toBe(200); // Adjust as per the response you expect | ||
expect(response.body.email).not.toContain('@'); // Ensure no @ in the email | ||
}); | ||
}); |