Skip to content

Commit

Permalink
Update get_mime_type.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Oct 19, 2023
1 parent 37ac1fd commit 5cd4fd0
Showing 1 changed file with 42 additions and 17 deletions.
59 changes: 42 additions & 17 deletions src/mime_types/get_mime_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
});
}
Expand Down

0 comments on commit 5cd4fd0

Please sign in to comment.