mime.test.ts22 lines · main
| 1 | import { describe, expect, it } from 'vitest' |
| 2 | |
| 3 | import { lookupMime } from './mime' |
| 4 | |
| 5 | describe('lookupMime', () => { |
| 6 | it('returns the correct mime type for a known extension', () => { |
| 7 | // 'html' is a common extension in mime-db |
| 8 | expect(lookupMime('html')).toBe('text/html') |
| 9 | }) |
| 10 | |
| 11 | it('returns undefined for an unknown extension', () => { |
| 12 | expect(lookupMime('notarealext')).toBeUndefined() |
| 13 | }) |
| 14 | |
| 15 | it('returns undefined for undefined input', () => { |
| 16 | expect(lookupMime(undefined)).toBeUndefined() |
| 17 | }) |
| 18 | |
| 19 | it('is case insensitive', () => { |
| 20 | expect(lookupMime('JPG')).toBe(lookupMime('jpg')) |
| 21 | }) |
| 22 | }) |