vitest implementation

This commit is contained in:
2026-03-16 18:38:15 +01:00
parent 2173ad6abf
commit ecb25ee322
70 changed files with 3560 additions and 1067 deletions

View File

@@ -1,5 +1,5 @@
import {TestBed} from '@angular/core/testing';
import {of} from 'rxjs';
import {firstValueFrom, of} from 'rxjs';
import {SongService} from './song.service';
import {SongListResolver} from './song-list.resolver';
@@ -22,11 +22,8 @@ describe('SongListResolver', () => {
expect(resolver).toBeTruthy();
});
it('should resolve the first emitted song list from the service', done => {
resolver.resolve().subscribe(songs => {
expect(songServiceSpy.listLoaded$).toHaveBeenCalled();
expect(songs).toEqual([{id: 'song-1', title: 'Amazing Grace'}] as never);
done();
});
it('should resolve the first emitted song list from the service', async () => {
await expectAsync(firstValueFrom(resolver.resolve())).toBeResolvedTo([{id: 'song-1', title: 'Amazing Grace'}] as never);
expect(songServiceSpy.listLoaded$).toHaveBeenCalled();
});
});

View File

@@ -1,5 +1,5 @@
import {TestBed} from '@angular/core/testing';
import {of} from 'rxjs';
import {firstValueFrom, of} from 'rxjs';
import {SongDataService} from './song-data.service';
import {SongService} from './song.service';
import {UserService} from '../../../services/user/user.service';
@@ -41,11 +41,8 @@ describe('SongService', () => {
expect(service).toBeTruthy();
});
it('should list songs from the data service', done => {
service.list$().subscribe(songs => {
expect(songs).toEqual([song]);
done();
});
it('should list songs from the data service', async () => {
await expectAsync(firstValueFrom(service.list$())).toBeResolvedTo([song]);
});
it('should delegate reads to the data service', async () => {

View File

@@ -38,7 +38,7 @@ Bridge
Cool bridge without any chords
`;
beforeEach(() => void TestBed.configureTestingModule({}));
beforeEach(async () => await TestBed.configureTestingModule({}));
it('should be created', () => {
const service: TextRenderingService = TestBed.inject(TextRenderingService);
@@ -478,13 +478,13 @@ Text`;
const service: TextRenderingService = TestBed.inject(TextRenderingService);
const text = 'Strophe\nC\tG\ta\nText';
void expect(service.validateChordNotation(text)).toContain(
void expect(service.validateChordNotation(text)).toEqual(expect.arrayContaining([
jasmine.objectContaining({
lineNumber: 2,
token: '\t',
reason: 'tab_character',
})
);
}),
]));
});
it('should not flag tabs on non chord lines', () => {

View File

@@ -7,8 +7,8 @@ import {Line} from './line';
describe('TransposeService', () => {
let service: TransposeService;
beforeEach(() => {
void TestBed.configureTestingModule({});
beforeEach(async () => {
await TestBed.configureTestingModule({});
service = TestBed.inject(TransposeService);
});