本文整理汇总了TypeScript中protocol/receiver.Receiver类的典型用法代码示例。如果您正苦于以下问题:TypeScript Receiver类的具体用法?TypeScript Receiver怎么用?TypeScript Receiver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Receiver类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe("message with no buffers", () => {
const r = new Receiver()
describe("header consume", () => {
it("should should leave message null", () => {
const res = r.consume('{"msgtype": "FOO", "msgid": "10"}')
expect(res).to.be.undefined
expect(r.message).to.be.null
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
describe("metadata consume", () => {
it("should should leave message null", () => {
const res = r.consume('{}')
expect(res).to.be.undefined
expect(r.message).to.be.null
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
describe("metadata consume", () => {
it("should should set a complete message", () => {
const res = r.consume('{"bar": "20"}')
expect(res).to.be.undefined
expect(r.message).to.be.instanceof(Message)
expect(r.message!.complete()).to.be.true
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
describe("next header consume", () => {
it("should should leave message null", () => {
const res = r.consume('{"msgtype": "FOO", "msgid": "11"}')
expect(res).to.be.undefined
expect(r.message).to.be.null
})
it("should throw an error on binary data", () => {
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
})
})
})
示例2: it
it("should should set a complete message", () => {
const res = r.consume(new ArrayBuffer(20))
expect(res).to.be.undefined
expect(r.message).to.be.instanceof(Message)
expect(r.message!.complete()).to.be.true
expect(r.message!.buffers.length).to.be.equal(2)
expect(r.message!.buffers[0].length).to.be.equal(2)
expect(r.message!.buffers[1].length).to.be.equal(2)
expect(r.message!.buffers[0][0]).to.be.equal('foo')
expect(r.message!.buffers[0][1]).to.be.instanceof(ArrayBuffer)
expect(r.message!.buffers[1][0]).to.be.equal('bar')
expect(r.message!.buffers[1][1]).to.be.instanceof(ArrayBuffer)
})
示例3: expect
expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)