summaryrefslogtreecommitdiff
path: root/src/node_modules/chance/test/test.music.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
committerMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
commit46e43f4bde4a35785b4997b81e86cd19f046b69b (patch)
treec53c2f826f777f9d6b2d249dab556feb72a6c3a6 /src/node_modules/chance/test/test.music.js
downloadlangdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip
Commit
Diffstat (limited to 'src/node_modules/chance/test/test.music.js')
-rw-r--r--src/node_modules/chance/test/test.music.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/node_modules/chance/test/test.music.js b/src/node_modules/chance/test/test.music.js
new file mode 100644
index 0000000..2910796
--- /dev/null
+++ b/src/node_modules/chance/test/test.music.js
@@ -0,0 +1,52 @@
+import test from 'ava'
+import Chance from '../chance.js'
+import _ from 'lodash'
+
+const chance = new Chance()
+
+// chance.note()
+test('note() returns a valid note', t => {
+ _.times(1000, () => {
+ let note = chance.note()
+ t.true(_.isString(note))
+ t.true(note.length <= 2)
+ })
+})
+
+// chance.midi_note()
+test('midi_note() returns a valid midi note between 0 and 127', t => {
+ _.times(1000, () => {
+ let midi_note = chance.midi_note()
+ t.true(_.isNumber(midi_note))
+ t.true(midi_note >= 0)
+ t.true(midi_note <= 127)
+ })
+})
+
+// chance.chord_quality()
+test('chord_quality() returns a valid chord quality', t => {
+ _.times(1000, () => {
+ let chord_quality = chance.chord_quality()
+ t.true(_.isString(chord_quality))
+ t.true(chord_quality.length <= 4)
+ })
+})
+
+// chance.chord()
+test('chord() returns a valid chord', t => {
+ _.times(1000, () => {
+ let chord = chance.chord()
+ t.true(_.isString(chord))
+ t.true(chord.length <= 6)
+ })
+})
+
+// chance.tempo()
+test('tempo() returns a valid tempo between 40 and 320', t => {
+ _.times(1000, () => {
+ let tempo = chance.tempo()
+ t.true(_.isNumber(tempo))
+ t.true(tempo >= 40)
+ t.true(tempo <= 320)
+ })
+}) \ No newline at end of file