forked from stojanovic/lambda-audio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lambda-audio-spec.js
52 lines (45 loc) · 1.73 KB
/
lambda-audio-spec.js
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
/* global describe, it, expect */
'use strict'
const path = require('path')
const underTest = require('../lib/lambda-audio')
const rainMp3Info = `
Input File : '/Users/slobodan/Github/lambda-sox/spec/files/rain.mp3'
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Duration : 00:00:07.89 = 347861 samples = 591.6 CDDA sectors
File Size : 126k
Bit Rate : 128k
Sample Encoding: MPEG audio (layer I, II or III)
`.replace(/ {21}/g, '')
describe('Lambda Audio', () => {
it('should export an object with three functions - sox, soxi and lame', () => {
['sox', 'soxi', 'lame'].forEach(item => expect(typeof underTest[item]).toBe('function'))
expect(typeof underTest).toBe('object')
})
it('should return a promise for each of the functions', () => {
['sox', 'soxi', 'lame'].forEach(item => {
const func = underTest[item](['-help'])
.catch(() => {})
expect(typeof func.then).toBe('function')
})
})
it('should show an info about the song if soxi is invoked with a file path as a string', done => {
underTest.soxi(path.join(__dirname, './files/rain.mp3'))
.then(info => {
expect(info).toBe(rainMp3Info)
return info
})
.then(done)
.catch(done.fail)
})
it('should show an info about the song if soxi is invoked with a file path as an array', done => {
underTest.soxi([path.join(__dirname, './files/rain.mp3')])
.then(info => {
expect(info).toBe(rainMp3Info)
return info
})
.then(done)
.catch(done.fail)
})
})