mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
MediaService: Refactor saveFile
The function now expects a `Note` object instead of a noteId and a `User` instead of a username to make it more consistent with other functions. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
341e3a3e5a
commit
fe26f1689c
9 changed files with 72 additions and 118 deletions
|
@ -157,8 +157,8 @@ describe('Notes', () => {
|
|||
describe('works', () => {
|
||||
it('with an existing alias and keepMedia false', async () => {
|
||||
const noteId = 'test3';
|
||||
await notesService.createNote(content, noteId, user);
|
||||
await mediaService.saveFile(testImage, user.userName, noteId);
|
||||
const note = await notesService.createNote(content, noteId, user);
|
||||
await mediaService.saveFile(testImage, user, note);
|
||||
await request(app.getHttpServer())
|
||||
.delete(`/notes/${noteId}`)
|
||||
.set('Content-Type', 'application/json')
|
||||
|
@ -174,12 +174,8 @@ describe('Notes', () => {
|
|||
});
|
||||
it('with an existing alias and keepMedia true', async () => {
|
||||
const noteId = 'test3a';
|
||||
await notesService.createNote(content, noteId, user);
|
||||
const url = await mediaService.saveFile(
|
||||
testImage,
|
||||
user.userName,
|
||||
noteId,
|
||||
);
|
||||
const note = await notesService.createNote(content, noteId, user);
|
||||
const url = await mediaService.saveFile(testImage, user, note);
|
||||
await request(app.getHttpServer())
|
||||
.delete(`/notes/${noteId}`)
|
||||
.set('Content-Type', 'application/json')
|
||||
|
@ -263,8 +259,8 @@ describe('Notes', () => {
|
|||
it('works', async () => {
|
||||
const alias = 'test6';
|
||||
const extraAlias = 'test7';
|
||||
await notesService.createNote(content, alias, user);
|
||||
await notesService.createNote(content, extraAlias, user);
|
||||
const note1 = await notesService.createNote(content, alias, user);
|
||||
const note2 = await notesService.createNote(content, extraAlias, user);
|
||||
const httpServer = app.getHttpServer();
|
||||
const response = await request(httpServer)
|
||||
.get(`/notes/${alias}/media/`)
|
||||
|
@ -273,12 +269,8 @@ describe('Notes', () => {
|
|||
expect(response.body).toHaveLength(0);
|
||||
|
||||
const testImage = await fs.readFile('test/private-api/fixtures/test.png');
|
||||
const url0 = await mediaService.saveFile(testImage, 'hardcoded', alias);
|
||||
const url1 = await mediaService.saveFile(
|
||||
testImage,
|
||||
'hardcoded',
|
||||
extraAlias,
|
||||
);
|
||||
const url0 = await mediaService.saveFile(testImage, user, note1);
|
||||
const url1 = await mediaService.saveFile(testImage, user, note2);
|
||||
|
||||
const responseAfter = await request(httpServer)
|
||||
.get(`/notes/${alias}/media/`)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue