Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("generates some chords without an error", function() {
let generator = new ChordGenerator(new KeySignature(0))
for (let i = 0; i < 10; i++) {
let chord = generator.nextChord()
expect(chord).toBeTruthy()
}
})
it("gets all chords for scale", function() {
let generator = new ChordGenerator(new KeySignature(0))
let chords = generator.allChords()
expect(chords).toEqual([
new Chord("C", "M"),
new Chord("D", "m"),
new Chord("E", "m"),
new Chord("F", "M"),
new Chord("G", "M"),
new Chord("A", "m"),
new Chord("B", "dim"),
])
})
create: function(staff, keySignature, options) {
return new ChordGenerator(keySignature, options)
}
},
if (!keySignature) {
this.setState({
currentCard: null
})
return
}
if (!this.generators) {
this.generators = {}
}
let generatorKey = `${keySignature.count}-${notes}`
if (!this.generators[generatorKey]) {
this.generators[generatorKey] = new ChordGenerator(keySignature, { notes })
}
let chord = this.generators[generatorKey].nextChord()
let inversion = this.props.settings.inversions ? this.rand.int() % 3 : 0
this.setState({
cardNumber: this.state.cardNumber + 1,
cardError: false,
cardMistakes: null,
partialAnswer: null,
currentCard: {
notes,
octave: 5,
keySignature,