1 | import test from 'ava'
|
2 | import Chance from '../chance.js'
|
3 | import _ from 'lodash'
|
4 |
|
5 | const chance = new Chance()
|
6 |
|
7 |
|
8 | test('note() returns a valid note', t => {
|
9 | _.times(1000, () => {
|
10 | let note = chance.note()
|
11 | t.true(_.isString(note))
|
12 | t.true(note.length <= 2)
|
13 | })
|
14 | })
|
15 |
|
16 |
|
17 | test('midi_note() returns a valid midi note between 0 and 127', t => {
|
18 | _.times(1000, () => {
|
19 | let midi_note = chance.midi_note()
|
20 | t.true(_.isNumber(midi_note))
|
21 | t.true(midi_note >= 0)
|
22 | t.true(midi_note <= 127)
|
23 | })
|
24 | })
|
25 |
|
26 |
|
27 | test('chord_quality() returns a valid chord quality', t => {
|
28 | _.times(1000, () => {
|
29 | let chord_quality = chance.chord_quality()
|
30 | t.true(_.isString(chord_quality))
|
31 | t.true(chord_quality.length <= 4)
|
32 | })
|
33 | })
|
34 |
|
35 |
|
36 | test('chord() returns a valid chord', t => {
|
37 | _.times(1000, () => {
|
38 | let chord = chance.chord()
|
39 | t.true(_.isString(chord))
|
40 | t.true(chord.length <= 6)
|
41 | })
|
42 | })
|
43 |
|
44 |
|
45 | test('tempo() returns a valid tempo between 40 and 320', t => {
|
46 | _.times(1000, () => {
|
47 | let tempo = chance.tempo()
|
48 | t.true(_.isNumber(tempo))
|
49 | t.true(tempo >= 40)
|
50 | t.true(tempo <= 320)
|
51 | })
|
52 | }) |
\ | No newline at end of file |