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,12 +1,74 @@
import {TestBed} from '@angular/core/testing';
import {EditService} from './edit.service';
describe('EditService', () => {
beforeEach(() => void TestBed.configureTestingModule({}));
let service: EditService;
beforeEach(() => {
void TestBed.configureTestingModule({});
service = TestBed.inject(EditService);
});
it('should be created', () => {
const service: EditService = TestBed.inject(EditService);
void expect(service).toBeTruthy();
expect(service).toBeTruthy();
});
it('should create a form with all editable song fields populated', () => {
const form = service.createSongForm({
text: 'Line 1',
title: 'Amazing Grace',
comment: 'Comment',
flags: 'fast',
key: 'G',
tempo: 90,
type: 'Praise',
status: 'final',
legalType: 'allowed',
legalOwner: 'CCLI',
legalOwnerId: '123',
artist: 'Artist',
label: 'Label',
termsOfUse: 'Use it',
origin: 'Origin',
} as never);
expect(form.getRawValue()).toEqual({
text: 'Line 1',
title: 'Amazing Grace',
comment: 'Comment',
flags: 'fast',
key: 'G',
tempo: 90,
type: 'Praise',
status: 'final',
legalType: 'allowed',
legalOwner: 'CCLI',
legalOwnerId: '123',
artist: 'Artist',
label: 'Label',
termsOfUse: 'Use it',
origin: 'Origin',
});
});
it('should default the status control to draft when the song has no status', () => {
const form = service.createSongForm({
text: '',
title: 'Untitled',
comment: '',
flags: '',
key: 'C',
tempo: 80,
type: 'Misc',
legalType: 'open',
legalOwner: 'other',
legalOwnerId: '',
artist: '',
label: '',
termsOfUse: '',
origin: '',
} as never);
expect(form.get('status')?.value).toBe('draft');
});
});