mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 15:14:56 -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
|
@ -111,26 +111,10 @@ describe('Me', () => {
|
|||
expect(responseBefore.body).toHaveLength(0);
|
||||
|
||||
const testImage = await fs.readFile('test/public-api/fixtures/test.png');
|
||||
const url0 = await mediaService.saveFile(
|
||||
testImage,
|
||||
'hardcoded',
|
||||
note1.publicId,
|
||||
);
|
||||
const url1 = await mediaService.saveFile(
|
||||
testImage,
|
||||
'hardcoded',
|
||||
note1.publicId,
|
||||
);
|
||||
const url2 = await mediaService.saveFile(
|
||||
testImage,
|
||||
'hardcoded',
|
||||
note2.alias ?? '',
|
||||
);
|
||||
const url3 = await mediaService.saveFile(
|
||||
testImage,
|
||||
'hardcoded',
|
||||
note2.alias ?? '',
|
||||
);
|
||||
const url0 = await mediaService.saveFile(testImage, user, note1);
|
||||
const url1 = await mediaService.saveFile(testImage, user, note1);
|
||||
const url2 = await mediaService.saveFile(testImage, user, note2);
|
||||
const url3 = await mediaService.saveFile(testImage, user, note2);
|
||||
|
||||
const response = await request(httpServer)
|
||||
.get('/me/media/')
|
||||
|
@ -163,11 +147,7 @@ describe('Me', () => {
|
|||
|
||||
it('DELETE /me', async () => {
|
||||
const testImage = await fs.readFile('test/public-api/fixtures/test.png');
|
||||
const url0 = await mediaService.saveFile(
|
||||
testImage,
|
||||
'hardcoded',
|
||||
note1.publicId,
|
||||
);
|
||||
const url0 = await mediaService.saveFile(testImage, user, note1);
|
||||
const dbUser = await userService.getUserByUsername('hardcoded');
|
||||
expect(dbUser).toBeInstanceOf(User);
|
||||
const mediaUploads = await mediaService.listUploadsByUser(dbUser);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue