smartmime/test/test.ts

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-03-04 14:21:44 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2023-07-11 22:32:17 +00:00
import * as smartmime from '../ts/index.js';
2020-03-04 14:21:44 +00:00
tap.test('should detect image', async () => {
const filePath = 'file.jpg';
const fileType = smartmime.detectMimeType(filePath);
console.log(fileType);
2023-07-11 22:32:17 +00:00
expect(smartmime.isBinary(filePath)).toBeTrue();
2020-03-04 14:21:44 +00:00
});
tap.test('should detect text', async () => {
const filePath = 'file.svg';
const fileType = smartmime.detectMimeType(filePath);
console.log(fileType);
2023-07-11 22:32:17 +00:00
expect(smartmime.isBinary(filePath)).toBeFalse();
2020-03-04 14:21:44 +00:00
});
tap.test('should detect json', async () => {
const filePath = 'file.json';
const fileType = smartmime.detectMimeType(filePath);
console.log(fileType);
2023-07-11 22:32:17 +00:00
expect(smartmime.isBinary(filePath)).toBeFalse();
2020-03-04 14:21:44 +00:00
});
tap.test('should detect html', async () => {
const filePath = 'file.html';
const fileType = smartmime.detectMimeType(filePath);
2023-07-11 22:32:17 +00:00
expect(fileType).toEqual('text/html');
2021-08-10 09:49:39 +00:00
console.log(fileType);
});
tap.test('should detect woff', async () => {
const filePath = 'file.woff';
const fileType = smartmime.detectMimeType(filePath);
2023-07-11 22:32:17 +00:00
expect(fileType).toEqual('font/woff');
2021-08-10 09:49:39 +00:00
console.log(fileType);
});
tap.test('should detect woff2', async () => {
const filePath = 'file.woff2';
const fileType = smartmime.detectMimeType(filePath);
2023-07-11 22:32:17 +00:00
expect(fileType).toEqual('font/woff2');
2020-03-04 14:21:44 +00:00
console.log(fileType);
});
tap.start();