当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript receiver.Receiver类代码示例

本文整理汇总了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)
        })
      })
    })
开发者ID:jsignell,项目名称:bokeh,代码行数:56,代码来源:receiver.ts

示例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)
 })
开发者ID:jsignell,项目名称:bokeh,代码行数:13,代码来源:receiver.ts

示例3: expect

 expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
开发者ID:jsignell,项目名称:bokeh,代码行数:1,代码来源:receiver.ts


注:本文中的protocol/receiver.Receiver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。