File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ const contentType = require ( '../../lib/content-type' ) ;
2+ const assert = require ( 'assert' ) ;
3+ const fs = require ( 'fs' ) ;
4+ const path = require ( 'path' ) ;
5+
6+ describe ( 'contentType' , ( ) => {
7+ it ( 'should return content type from a filename' , ( ) => {
8+ const fname = 'fake.mp3' ;
9+ assert ( contentType . fromFilename ( fname ) === 'audio/mp3' ) ;
10+ } ) ;
11+ it ( 'should return content type from a File object' , ( ) => {
12+ const File = {
13+ name : 'fake.mp3'
14+ } ;
15+ assert ( contentType . fromFilename ( File ) === 'audio/mp3' ) ;
16+ } ) ;
17+ it ( 'should return undefined for an empty input' , ( ) => {
18+ assert ( contentType . fromFilename ( { } ) === undefined ) ;
19+ } ) ;
20+ it ( 'should return content type from a buffer' , ( ) => {
21+ const buffer = fs . readFileSync (
22+ path . join ( __dirname , '../resources/blank.wav' )
23+ ) ;
24+ assert ( contentType . fromHeader ( buffer ) === 'audio/wav' ) ;
25+ } ) ;
26+ } ) ;
You can’t perform that action at this time.
0 commit comments