當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript receiver.Receiver類代碼示例

本文整理匯總了TypeScript中@bokehjs/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:digitalsatori,項目名稱: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:digitalsatori,項目名稱:Bokeh,代碼行數:13,代碼來源:receiver.ts

示例3: expect

 expect(() => r.consume(new ArrayBuffer(10))).to.throw(Error)
開發者ID:digitalsatori,項目名稱:Bokeh,代碼行數:1,代碼來源:receiver.ts


注:本文中的@bokehjs/protocol/receiver.Receiver類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。