diff --git a/src/model/Beat.ts b/src/model/Beat.ts index 0c1866dd9..9ec08724b 100644 --- a/src/model/Beat.ts +++ b/src/model/Beat.ts @@ -502,6 +502,9 @@ export class Beat { let index: number = this.notes.indexOf(note); if (index >= 0) { this.notes.splice(index, 1); + if (note.isStringed) { + this.noteStringLookup.delete(note.string); + } } } diff --git a/test/model/Beat.test.ts b/test/model/Beat.test.ts new file mode 100644 index 000000000..203acc057 --- /dev/null +++ b/test/model/Beat.test.ts @@ -0,0 +1,25 @@ +import { Note } from '@src/model'; +import { Beat } from '@src/model/Beat'; + +describe('BeatTests', () => { + it('add-stringed-note', () => { + const beat = new Beat(); + const note = new Note(); + note.string = 2; + beat.addNote(note); + expect(beat.notes.length).toBe(1); + expect(beat.hasNoteOnString(2)).toBe(true); + expect(beat.getNoteOnString(2)).toBe(note); + }); + + it('remove-stringed-note', () => { + const beat = new Beat(); + const note = new Note(); + note.string = 1; + beat.addNote(note); + beat.removeNote(note); + expect(beat.notes.length).toBe(0); + expect(beat.hasNoteOnString(2)).toBe(false); + expect(beat.getNoteOnString(2)).toBe(null); + }); +}); \ No newline at end of file