UNPKG

@infinito/id3

Version:
25 lines (22 loc) 935 B
import assert from 'assert'; import path from 'path'; import findFiles from '@infinito/get-files'; import getTagBuffer from '../src/get.tagbuf.js'; describe('getTagBuffer', function () { it('should throw a TypeError when not given a path', function () { assert.throws(() => getTagBuffer(),TypeError); }); it('should throw a TypeError when given a path that\'s not a string', function () { assert.throws(() => getTagBuffer(1),TypeError); }); it('should fail when given a path to a file that\'s not a valid .mp3', function () { assert.throws(() => getTagBuffer(__filename),Error); }); it('should succeed when given an .mp3 file', function () { const filePaths = findFiles(path.resolve(__dirname,'..','music'),".mp3"); if(filePaths.length==0) { assert.fail('No music files in /music directory; can\'t test getTagBuffer'); } assert.doesNotThrow(() => getTagBuffer(filePaths[0])); }); });