optimize song usage

This commit is contained in:
2026-03-15 13:19:20 +01:00
parent d907c89eb6
commit ab535d48b9
21 changed files with 312 additions and 29 deletions

View File

@@ -3,6 +3,11 @@ import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
import {SongComponent} from './song.component';
import {of} from 'rxjs';
import {ActivatedRoute} from '@angular/router';
import {SongService} from '../services/song.service';
import {FileDataService} from '../services/file-data.service';
import {UserService} from '../../../services/user/user.service';
import {ShowService} from '../../shows/services/show.service';
import {ShowSongService} from '../../shows/services/show-song.service';
describe('SongComponent', () => {
let component: SongComponent;
@@ -13,9 +18,28 @@ describe('SongComponent', () => {
};
beforeEach(waitForAsync(() => {
const songServiceSpy = jasmine.createSpyObj<SongService>('SongService', ['read$']);
const fileDataServiceSpy = jasmine.createSpyObj<FileDataService>('FileDataService', ['read$']);
const userServiceSpy = jasmine.createSpyObj<UserService>('UserService', ['incSongCount', 'decSongCount'], {
user$: of({id: 'user-1', name: 'Benjamin', role: 'leader', chordMode: 'onlyFirst', songUsage: {'4711': 2}}),
});
const showServiceSpy = jasmine.createSpyObj<ShowService>('ShowService', ['list$', 'update$']);
const showSongServiceSpy = jasmine.createSpyObj<ShowSongService>('ShowSongService', ['new$']);
songServiceSpy.read$.and.returnValue(of({id: '4711', title: 'Test Song', number: '1', text: '', showType: '', flags: ''} as never));
fileDataServiceSpy.read$.and.returnValue(of([]));
showServiceSpy.list$.and.returnValue(of([]));
void TestBed.configureTestingModule({
imports: [SongComponent],
providers: [{provide: ActivatedRoute, useValue: mockActivatedRoute}],
providers: [
{provide: ActivatedRoute, useValue: mockActivatedRoute},
{provide: SongService, useValue: songServiceSpy},
{provide: FileDataService, useValue: fileDataServiceSpy},
{provide: UserService, useValue: userServiceSpy},
{provide: ShowService, useValue: showServiceSpy},
{provide: ShowSongService, useValue: showSongServiceSpy},
],
}).compileComponents();
}));