-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
note_list_spec.es6
76 lines (57 loc) 路 2.03 KB
/
note_list_spec.es6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import "jasmine_boot"
import NoteList from "st/note_list"
describe("NoteList", function() {
describe("matchesHead", function() {
it("matches with singular notes", function () {
const notes = new NoteList([
"D5",
"C5",
])
expect(notes.matchesHead(["D5"])).toBe(true)
expect(notes.matchesHead(["D6"])).toBe(false)
expect(notes.matchesHead(["C5"])).toBe(false)
// singular notes wrapped in array
const notes2 = new NoteList([
["D5"],
["C5"],
])
expect(notes2.matchesHead(["D5"])).toBe(true)
expect(notes2.matchesHead(["C5"])).toBe(false)
const enharmonic = new NoteList([ "C#4" ])
expect(enharmonic.matchesHead(["Db4"])).toBe(true)
const enharmonic2 = new NoteList([ "Bb4" ])
expect(enharmonic2.matchesHead(["A#4"])).toBe(true)
// wrapped
const enharmonic3 = new NoteList([ ["C#4"] ])
expect(enharmonic3.matchesHead(["Db4"])).toBe(true)
const enharmonic4 = new NoteList([ ["Bb4"] ])
expect(enharmonic4.matchesHead(["A#4"])).toBe(true)
})
it("matches with multiple notes", function () {
const notes = new NoteList([
["D5", "C5"],
])
expect(notes.matchesHead(["C5"])).toBe(false)
expect(notes.matchesHead(["C5", "D5"])).toBe(true)
expect(notes.matchesHead(["D5", "C5"])).toBe(true)
expect(notes.matchesHead(["D6", "C5"])).toBe(false)
})
it("matches with singular notes, anyOctave", function () {
const notes = new NoteList([
"D5",
"C5",
])
expect(notes.matchesHead(["D5"], true)).toBe(true)
expect(notes.matchesHead(["D6"], true)).toBe(true)
expect(notes.matchesHead(["C5"], true)).toBe(false)
// singular notes wrapped in array
const notes2 = new NoteList([
["D5"],
["C5"],
])
expect(notes2.matchesHead(["D5"], true)).toBe(true)
expect(notes2.matchesHead(["D6"], true)).toBe(true)
expect(notes2.matchesHead(["C5"], true)).toBe(false)
})
})
})