Remove buffer dependency
This commit is contained in:
@@ -5,7 +5,7 @@ test('Test number conversion to Uint16 big endian buffer.', () => {
|
||||
const result = numberToUint16BE(1234)
|
||||
|
||||
// Then
|
||||
const expectedResult = Buffer.from([0x04, 0xd2])
|
||||
const expectedResult = new Uint8Array([0x04, 0xd2])
|
||||
expect(result).toMatchObject(expectedResult)
|
||||
})
|
||||
|
||||
@@ -14,6 +14,6 @@ test('Test number conversion to Uint32 big endian buffer.', () => {
|
||||
const result = numberToUint32BE(123456)
|
||||
|
||||
// Then
|
||||
const expectedResult = Buffer.from([0x00, 0x01, 0xE2, 0x40])
|
||||
const expectedResult = new Uint8Array([0x00, 0x01, 0xE2, 0x40])
|
||||
expect(result).toMatchObject(expectedResult)
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ test('Read a buffer.', () => {
|
||||
|
||||
// Then
|
||||
const result = smartBuffer.readBytes(4)
|
||||
expect(result).toMatchObject(Buffer.from([0, 1, 2, 3]))
|
||||
expect(result).toMatchObject(new Uint8Array([0, 1, 2, 3]))
|
||||
})
|
||||
|
||||
test('Read a UInt16 from an offset.', () => {
|
||||
@@ -67,7 +67,7 @@ test('Read a buffer from an offset.', () => {
|
||||
smartBuffer.cursor = 2
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.readBytes(4)).toMatchObject(Buffer.from([2, 3, 4, 5]))
|
||||
expect(smartBuffer.readBytes(4)).toMatchObject(new Uint8Array([2, 3, 4, 5]))
|
||||
})
|
||||
|
||||
test('Write a UInt16.', () => {
|
||||
@@ -78,7 +78,7 @@ test('Write a UInt16.', () => {
|
||||
smartBuffer.writeUInt16(12345)
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.data).toMatchObject(Buffer.from([0x30, 0x39]))
|
||||
expect(smartBuffer.data).toMatchObject(new Uint8Array([0x30, 0x39]))
|
||||
})
|
||||
|
||||
test('Write a UInt32.', () => {
|
||||
@@ -89,7 +89,7 @@ test('Write a UInt32.', () => {
|
||||
smartBuffer.writeUInt32(1234567890)
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.data).toMatchObject(Buffer.from([0x49, 0x96, 0x02, 0xD2]))
|
||||
expect(smartBuffer.data).toMatchObject(new Uint8Array([0x49, 0x96, 0x02, 0xD2]))
|
||||
})
|
||||
|
||||
test('Write a buffer.', () => {
|
||||
@@ -100,7 +100,7 @@ test('Write a buffer.', () => {
|
||||
smartBuffer.writeBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.data).toMatchObject(Buffer.from([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
|
||||
expect(smartBuffer.data).toMatchObject(new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
|
||||
})
|
||||
|
||||
test('Write a UInt16 at an offset.', () => {
|
||||
@@ -112,7 +112,7 @@ test('Write a UInt16 at an offset.', () => {
|
||||
smartBuffer.writeUInt16(12345)
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.data).toMatchObject(Buffer.from([0x00, 0x00, 0x30, 0x39]))
|
||||
expect(smartBuffer.data).toMatchObject(new Uint8Array([0x00, 0x00, 0x30, 0x39]))
|
||||
})
|
||||
|
||||
test('Write a UInt32 at an offset.', () => {
|
||||
@@ -124,7 +124,7 @@ test('Write a UInt32 at an offset.', () => {
|
||||
smartBuffer.writeUInt32(1234567890)
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.data).toMatchObject(Buffer.from([0x00, 0x00, 0x49, 0x96, 0x02, 0xD2]))
|
||||
expect(smartBuffer.data).toMatchObject(new Uint8Array([0x00, 0x00, 0x49, 0x96, 0x02, 0xD2]))
|
||||
})
|
||||
|
||||
test('Write a buffer at an offset.', () => {
|
||||
@@ -136,7 +136,7 @@ test('Write a buffer at an offset.', () => {
|
||||
smartBuffer.writeBytes([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
||||
|
||||
// Then
|
||||
expect(smartBuffer.data).toMatchObject(Buffer.from([0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
|
||||
expect(smartBuffer.data).toMatchObject(new Uint8Array([0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))
|
||||
})
|
||||
|
||||
test('Cursor is correctly incremented after reading a UInt16.', () => {
|
||||
|
||||
Reference in New Issue
Block a user