From 5cd4fd0b01f13ae91c9ca535555871a923c04781 Mon Sep 17 00:00:00 2001 From: Mqxx <62719703+Mqxx@users.noreply.github.com> Date: Thu, 19 Oct 2023 16:50:19 +0200 Subject: [PATCH] Update get_mime_type.test.ts --- src/mime_types/get_mime_type.test.ts | 59 ++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/src/mime_types/get_mime_type.test.ts b/src/mime_types/get_mime_type.test.ts index a7243b3..c903994 100644 --- a/src/mime_types/get_mime_type.test.ts +++ b/src/mime_types/get_mime_type.test.ts @@ -4,34 +4,59 @@ import { getMIMEType } from "./get_mime_type.ts"; Deno.test( 'Get MIME type for specific file extension.', async (test) => { - await test.step({ - name: 'html', - fn: () => { - assertEquals(getMIMEType('html'), 'text/html'); - } - }); - await test.step({ - name: 'css', - fn: () => { - assertEquals(getMIMEType('css'), 'text/css'); + const defaultMIMETypes = { + default: 'text/html', + types: { + 'text/html': [ + 'html' + ], + 'application/javascript': [ + "js", + "mjs" + ] } - }); + } + await test.step({ - name: 'js', + name: 'Get simple entry (html)', fn: () => { - assertEquals(getMIMEType('js'), 'application/javascript'); + assertEquals( + getMIMEType( + defaultMIMETypes, + 'html' + ), 'text/html' + ); } }); await test.step({ - name: 'txt', + name: 'Get entry in array (js/mjs)', fn: () => { - assertEquals(getMIMEType('txt'), 'text/plain'); + assertEquals( + getMIMEType( + defaultMIMETypes, + 'js' + ), + 'application/javascript' + ); + assertEquals( + getMIMEType( + defaultMIMETypes, + 'jsm' + ), + 'application/javascript' + ); } }); await test.step({ - name: 'doesNotExist', + name: 'Get default entry, if extension does not exist.', fn: () => { - assertEquals(getMIMEType('doesNotExist'), 'text/plain'); + assertEquals( + getMIMEType( + defaultMIMETypes, + 'doesNotExist' + ), + 'text/plain' + ); } }); }