add unit tests

This commit is contained in:
2026-03-10 00:05:08 +01:00
parent db6a230696
commit 7170e4a08e
17 changed files with 862 additions and 50 deletions

View File

@@ -1,4 +1,4 @@
import {EnvironmentInjector, Injectable, inject, runInInjectionContext} from '@angular/core';
import {EnvironmentInjector, inject, Injectable, runInInjectionContext} from '@angular/core';
import {deleteObject, getDownloadURL, ref, Storage} from '@angular/fire/storage';
import {from, Observable} from 'rxjs';
import {FileDataService} from './file-data.service';
@@ -12,11 +12,19 @@ export class FileService {
private environmentInjector = inject(EnvironmentInjector);
public getDownloadUrl(path: string): Observable<string> {
return from(runInInjectionContext(this.environmentInjector, () => getDownloadURL(ref(this.storage, path))));
return from(runInInjectionContext(this.environmentInjector, () => this.resolveDownloadUrl(path)));
}
public delete(path: string, songId: string, fileId: string): void {
void runInInjectionContext(this.environmentInjector, () => deleteObject(ref(this.storage, path)));
void runInInjectionContext(this.environmentInjector, () => this.deleteFromStorage(path));
void this.fileDataService.delete(songId, fileId);
}
private resolveDownloadUrl(path: string): Promise<string> {
return getDownloadURL(ref(this.storage, path));
}
private deleteFromStorage(path: string): Promise<void> {
return deleteObject(ref(this.storage, path));
}
}