smartbuffer/test/test.both.ts

22 lines
721 B
TypeScript
Raw Permalink Normal View History

2024-02-25 00:45:48 +00:00
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
2022-06-15 21:36:51 +00:00
import * as smartbuffer from '../ts/index.js';
tap.test('first test', async () => {
console.log(smartbuffer);
});
2024-02-25 00:45:48 +00:00
tap.test('should recognize different buffer like objects', async () => {
2024-02-29 21:43:37 +00:00
// const testBuffer = Buffer.from('test');
2024-02-25 00:45:48 +00:00
const testArrayBuffer = new ArrayBuffer(4);
const testUint8Array = new Uint8Array(testArrayBuffer);
testUint8Array[0] = 116;
testUint8Array[1] = 101;
testUint8Array[2] = 115;
testUint8Array[3] = 116;
2024-02-29 21:43:37 +00:00
// expect(smartbuffer.isBufferLike(testBuffer)).toBeTrue();
2024-02-25 00:45:48 +00:00
expect(smartbuffer.isBufferLike(testArrayBuffer)).toBeTrue();
expect(smartbuffer.isBufferLike(testUint8Array)).toBeTrue();
});
2022-06-15 21:36:51 +00:00
tap.start();