BREAKING CHANGE(core): update

This commit is contained in:
2024-05-21 00:57:24 +02:00
parent 70dc0ef68f
commit 139b31be07
9 changed files with 5234 additions and 3207 deletions

View File

@ -1,45 +1,63 @@
import { expect, tap } from '@pushrocks/tapbundle';
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartmime from '../ts/index.js';
tap.test('should detect image', async () => {
const filePath = 'file.jpg';
const fileType = smartmime.detectMimeType(filePath);
const fileType = await smartmime.detectMimeType({
path: filePath,
});
console.log(fileType);
expect(smartmime.isBinary(filePath)).toBeTrue();
expect(await smartmime.isBinary({
path: filePath,
})).toBeTrue();
});
tap.test('should detect text', async () => {
const filePath = 'file.svg';
const fileType = smartmime.detectMimeType(filePath);
const fileType = await smartmime.detectMimeType({
path: filePath,
});
console.log(fileType);
expect(smartmime.isBinary(filePath)).toBeFalse();
expect(await smartmime.isBinary({
path: filePath,
})).toBeFalse();
});
tap.test('should detect json', async () => {
const filePath = 'file.json';
const fileType = smartmime.detectMimeType(filePath);
const fileType = await smartmime.detectMimeType({
path: filePath,
});
console.log(fileType);
expect(smartmime.isBinary(filePath)).toBeFalse();
expect(await smartmime.isBinary({
path: filePath,
})).toBeFalse();
});
tap.test('should detect html', async () => {
const filePath = 'file.html';
const fileType = smartmime.detectMimeType(filePath);
expect(fileType).toEqual('text/html');
const fileType = await smartmime.detectMimeType({
path: filePath,
});
expect(fileType.mime).toEqual('text/html');
console.log(fileType);
});
tap.test('should detect woff', async () => {
const filePath = 'file.woff';
const fileType = smartmime.detectMimeType(filePath);
expect(fileType).toEqual('font/woff');
const fileType = await smartmime.detectMimeType({
path: filePath,
});
expect(fileType.mime).toEqual('font/woff');
console.log(fileType);
});
tap.test('should detect woff2', async () => {
const filePath = 'file.woff2';
const fileType = smartmime.detectMimeType(filePath);
expect(fileType).toEqual('font/woff2');
const fileType = await smartmime.detectMimeType({
path: filePath,
});
expect(fileType.mime).toEqual('font/woff2');
console.log(fileType);
});