smartbuffer/test/test.both.ts
2024-02-29 22:43:37 +01:00

22 lines
721 B
TypeScript

import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as smartbuffer from '../ts/index.js';
tap.test('first test', async () => {
console.log(smartbuffer);
});
tap.test('should recognize different buffer like objects', async () => {
// const testBuffer = Buffer.from('test');
const testArrayBuffer = new ArrayBuffer(4);
const testUint8Array = new Uint8Array(testArrayBuffer);
testUint8Array[0] = 116;
testUint8Array[1] = 101;
testUint8Array[2] = 115;
testUint8Array[3] = 116;
// expect(smartbuffer.isBufferLike(testBuffer)).toBeTrue();
expect(smartbuffer.isBufferLike(testArrayBuffer)).toBeTrue();
expect(smartbuffer.isBufferLike(testUint8Array)).toBeTrue();
});
tap.start();