smartjimp/test/test.ts
2023-11-24 20:08:48 +01:00

19 lines
826 B
TypeScript

import { expect, tap } from '@push.rocks/tapbundle';
import * as smartjimp from '../ts/index.js';
import * as smartfile from '@push.rocks/smartfile';
let testSmartJimp: smartjimp.SmartJimp;
tap.test('first test', async () => {
testSmartJimp = new smartjimp.SmartJimp();
expect(testSmartJimp).toBeInstanceOf(smartjimp.SmartJimp);
});
tap.test('should be able to create a master', async () => {
const smartfileInstance = await smartfile.SmartFile.fromUrl('https://images.unsplash.com/photo-1673276628202-737bf3020ac2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3774&q=80')
const convertedAsset = await testSmartJimp.getFromSmartfile(smartfileInstance, {width: 500});
(await smartfile.SmartFile.fromBuffer('.nogit/result.avif', convertedAsset)).write();
});
tap.start();