This commit is contained in:
2020-03-16 21:10:06 +01:00
committed by smuddy
parent 5e6a30d0e4
commit 5dd95153bb
2 changed files with 7 additions and 8 deletions

View File

@@ -60,15 +60,15 @@ Cool bridge without any chords
it('should parse chord lines', () => { it('should parse chord lines', () => {
const service: TextRenderingService = TestBed.get(TextRenderingService); const service: TextRenderingService = TestBed.get(TextRenderingService);
const sections = service.parse(testText); const sections = service.parse(testText);
expect(sections[0].lines[0].type).toBe(LineType.chrod); expect(sections[0].lines[0].type).toBe(LineType.chord);
expect(sections[0].lines[0].text).toBe('C D E F G A H'); expect(sections[0].lines[0].text).toBe('C D E F G A H');
expect(sections[0].lines[2].type).toBe(LineType.chrod); expect(sections[0].lines[2].type).toBe(LineType.chord);
expect(sections[0].lines[2].text).toBe(' a d e f g a h c b'); expect(sections[0].lines[2].text).toBe(' a d e f g a h c b');
expect(sections[1].lines[0].type).toBe(LineType.chrod); expect(sections[1].lines[0].type).toBe(LineType.chord);
expect(sections[1].lines[0].text).toBe('C D E F G A H'); expect(sections[1].lines[0].text).toBe('C D E F G A H');
expect(sections[1].lines[2].type).toBe(LineType.chrod); expect(sections[1].lines[2].type).toBe(LineType.chord);
expect(sections[1].lines[2].text).toBe(' a d e f g a h c b'); expect(sections[1].lines[2].text).toBe(' a d e f g a h c b');
expect(sections[2].lines[0].type).toBe(LineType.chrod); expect(sections[2].lines[0].type).toBe(LineType.chord);
expect(sections[2].lines[0].text).toBe('c# cb c7 cmaj7 c/e'); expect(sections[2].lines[0].text).toBe('c# cb c7 cmaj7 c/e');
}); });
}); });

View File

@@ -7,8 +7,7 @@ export enum SectionType {
} }
export enum LineType { export enum LineType {
title, chord,
chrod,
text, text,
} }
@@ -49,7 +48,7 @@ export class TextRenderingService {
private getLineOfLineText(text: string): Line { private getLineOfLineText(text: string): Line {
const matches = !!text.match(this.regexChords); const matches = !!text.match(this.regexChords);
const type = matches ? LineType.chrod : LineType.text; const type = matches ? LineType.chord : LineType.text;
return {type, text} return {type, text}
} }