diff options
Diffstat (limited to 'test/js/node/stream/bufferlist.test.ts')
-rw-r--r-- | test/js/node/stream/bufferlist.test.ts | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/test/js/node/stream/bufferlist.test.ts b/test/js/node/stream/bufferlist.test.ts index 8ab147d7e..8a3870772 100644 --- a/test/js/node/stream/bufferlist.test.ts +++ b/test/js/node/stream/bufferlist.test.ts @@ -38,9 +38,7 @@ it("should fail on .concat() with invalid items", () => { const list = new Readable().readableBuffer; expect(list.length).toBe(0); expect(list.push("foo")).toBeUndefined(); - expect(() => { - list.concat(42); - }).toThrow(TypeError); + list.concat(42); }); it("should fail on .concat() buffer overflow", () => { @@ -63,7 +61,7 @@ it("should work with .consume() on strings", () => { // @ts-ignore const list = new Readable().readableBuffer; expect(list.length).toBe(0); - expect(list.consume(42, true)).toBe(""); + expect(() => list.consume()).toThrow(); expect(list.push("foo")).toBeUndefined(); expect(list.push("bar")).toBeUndefined(); expect(list.push("baz")).toBeUndefined(); @@ -82,7 +80,7 @@ it("should work with .consume() on buffers", () => { // @ts-ignore const list = new Readable().readableBuffer; expect(list.length).toBe(0); - expect(list.consume(42, false)).toEqual(new Uint8Array()); + expect(() => list.consume()).toThrow(); expect(list.push(makeUint8Array("foo"))).toBeUndefined(); expect(list.push(makeUint8Array("bar"))).toBeUndefined(); expect(list.push(makeUint8Array("baz"))).toBeUndefined(); @@ -105,26 +103,21 @@ it("should fail on .consume() with invalid items", () => { expect(list.length).toBe(0); expect(list.push("foo")).toBeUndefined(); expect(list.length).toBe(1); - expect(list.consume(0, false)).toEqual(new Uint8Array([])); - expect(() => { - list.consume(1, false); - }).toThrow(TypeError); - expect(list.consume(3, true)).toBe("foo"); + expect(list.consume(0, false)).toEqual(''); + expect(list.consume(1, false)).toEqual('f'); + expect(list.consume(2, true)).toBe("oo"); expect(list.length).toBe(0); expect(list.push(makeUint8Array("bar"))).toBeUndefined(); expect(list.length).toBe(1); - expect(list.consume(0, true)).toEqual(""); - expect(() => { - list.consume(1, true); - }).toThrow(TypeError); - expect(list.consume(3, false)).toEqual(new Uint8Array([98, 97, 114])); + expect(list.consume(0, true).byteLength).toEqual(0); + expect(list.consume(1, true)[0]).toEqual(98); }); it("should work with .first()", () => { // @ts-ignore const list = new Readable().readableBuffer; expect(list.length).toBe(0); - expect(list.first()).toBeUndefined(); + expect(() => list.first()).toThrow(); const item = {}; expect(list.push(item)).toBeUndefined(); expect(list.length).toBe(1); |